如何使用python推送百度站长收录数据

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. import sys
  4. import requests
  5. from bs4 import BeautifulSoup
  6.  
  7.  
  8. reload(sys)
  9. sys.setdefaultencoding("utf8")
  10.  
  11. text = requests.get("https://www.stock4p.com/").text
  12.  
  13. bs4 = BeautifulSoup(text)
  14. excerpts = bs4.select(".excerpt")
  15. post_url = []
  16. for exce in excerpts:
  17. h = exce.select_one("header h2 a").attrs['href']
  18. post_url.append(h)
  19.  
  20. # post_url = ['https://www.stock4p.com/2020/06/13/pyppeteer%e6%8a%93%e5%8f%96%e6%95%b0%e6%8d%ae%e4%b9%8b%e7%9b%b4%e6%8e%a5%e6%8a%93%e5%8f%96http%e8%af%b7%e6%b1%82/']
  21. post_data = '\n'.join(post_url)
  22. #
  23. #
  24. t = requests.post("http://data.zz.baidu.com/urls?site=www.stock4p.com&token=123456", data=post_data).text
  25. #
  26. print t
  27. #
  28. #

你可能感兴趣的:(如何使用python推送百度站长收录数据)