Skip to content

Instantly share code, notes, and snippets.

@tvorogme
Created November 24, 2016 07:48
Show Gist options
  • Save tvorogme/4a66e068db4f14820c176ebbb7dd4d7d to your computer and use it in GitHub Desktop.
Save tvorogme/4a66e068db4f14820c176ebbb7dd4d7d to your computer and use it in GitHub Desktop.
from urllib.request import urlopen
from concurrent import futures
import pickle
site = "http://izvestia.ru/news/"
last_publication = 646946
start = 500000
answer = []
def get_page(n):
api_html = urlopen(site+str(n)).read().decode()
answer.append(api_html)
print('\r', len(answer), end="")
with futures.ThreadPoolExecutor(50) as executor:
executor.map(get_page, range(start, last_publication))
pickle.dump(answer, open('izvestya.pck','wb'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment