Skip to content

Instantly share code, notes, and snippets.

@IanSmith123
Created April 11, 2019 11:16
Show Gist options
  • Save IanSmith123/0d82094181fb067870d1ff98b6692f23 to your computer and use it in GitHub Desktop.
Save IanSmith123/0d82094181fb067870d1ff98b6692f23 to your computer and use it in GitHub Desktop.
获取vista看天下《天下焦点》链接
import json
from concurrent.futures import ThreadPoolExecutor
import requests
pool = ThreadPoolExecutor(10)
sample = "http://v20.tp.wkread.com/index.php/WeiXin/Focus/getColumnList/id/103"
def get_content(uid):
print("get {}".format(uid))
base_url = "http://v20.tp.wkread.com/index.php/WeiXin/Focus/getColumnList/id/"
url = "{}{}".format(base_url, uid)
r = requests.get(url)
if r.json():
save(uid, r.json())
def save(uid, j):
with open("content/{}.json".format(uid), 'w', encoding='u8') as f:
f.write(json.dumps(j, ensure_ascii=False, indent=2))
print("save {}".format(uid))
l = []
for i in range(1, 1033):
p = pool.submit(get_content, i)
l.append(p)
[i.result() for i in l]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment