get_one_page.py 726 B

12345678910111213141516171819202122232425
  1. import requests
  2. def get_one_page(keyword, page, date_begin, date_end, proxy_ip, cookie, user_agent):
  3. user = "lutingsong"
  4. password = "6cac3hci"
  5. proxie = {
  6. 'http': 'http://' + user + ':' + password + '@' + proxy_ip,
  7. 'https': 'https://' + user + ':' + password + '@' + proxy_ip
  8. }
  9. params = {
  10. 'q': f'{keyword}',
  11. 'typeall': 1,
  12. 'suball': 1,
  13. 'timescope': 'custom:' + date_begin + ':' + date_end,
  14. 'Refer': 'g',
  15. 'page': page,
  16. }
  17. headers = {
  18. 'Cookie': cookie,
  19. 'User_Agent': user_agent
  20. }
  21. url = 'https://s.weibo.com/weibo?' # 请求api
  22. html = requests.get(url, params=params, headers=headers).content
  23. return html