如何使用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. #
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值