GithubHelp home page GithubHelp logo

seanhuai / tumblr-source-list Goto Github PK

View Code? Open in Web Editor NEW
61.0 61.0 20.0 15 KB

一个Tumblr资源工具,用于获取图片或视频信息

Home Page: https://seanhuai.github.io/2017/08/tumblr-source-list

License: MIT License

Python 100.00%

tumblr-source-list's People

Contributors

seanhuai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tumblr-source-list's Issues

您好,我是使用这个脚本的时候出现了一个问题

PS E:\code\git\tumblr-source-list> python .\app.py posturl https://wsyghf.tumblr.com/post/150478441406/
Traceback (most recent call last):
File ".\app.py", line 5, in
from packages._funcs import *
File "E:\code\git\tumblr-source-list\packages_funcs.py", line 3, in
from packages._proxy import *
File "E:\code\git\tumblr-source-list\packages_proxy.py", line 3, in
from urllib import request
ImportError: cannot import name request

这是我的命令行信息,请问是什么问题导致的?这个脚本使用的python版本是多少呢~
谢谢~

分页貌似不能正常翻页

api 中offset 参数并不是多少也 这个值是从那个位置其后20条记录

我根据您的代码我修改了下 获取这个博客的所有posts 内的vedio 或者phtoto

from urllib import request
import json


proxy_handler = request.ProxyHandler({'http': 'http://127.0.0.1:1080/'})
opener = request.build_opener(proxy_handler)

url = 'http://api.tumblr.com/v2/blog/{username}.tumblr.com/posts/{mediatype}?api_key=fuiKNFp9vQFvjLNvx4sUwti4Yb5yGutBN4Xh10LXZhhRKjWlV4&offset={offset}'

infourl = 'http://api.tumblr.com/v2/blog/{username}.tumblr.com/info?api_key=fuiKNFp9vQFvjLNvx4sUwti4Yb5yGutBN4Xh10LXZhhRKjWlV4'
username = 'wsyghf'
mediatype='video'

f = opener.open(infourl.format(username=username))
j_f = json.loads(f.read())
print(j_f)
total_posts = j_f['response']['blog']['total_posts']
urls = []
for i in range(int(total_posts/20)+1):
	urls.append(url.format(username=username, mediatype=mediatype, offset=i*20))

def get_v(url):
	f = opener.open(url)
	d1 = json.load(f)
	v = []
	for i in d1['response']['posts']:
		if mediatype == 'video':
			v.append(i['video_url'])
		else:
			for i1 in i['photos']:
				v.append(i1['original_size']['url'])
	return v

c = {}

for u in urls:
	for cc in get_v(u):
		c[cc] = ''
print(c)
with open('all{username}_{mediatype}.txt'.format(mediatype=mediatype, username=username), 'w') as f:
	for u1 in c.keys():
		f.write(u1+'\n')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.