Loading... ## 话不多说,直接上源代码 ### 需要导入的模块包 ```python import requests from bs4 import BeautifulSoup ``` ### 提交给百度收录的api函数 ```python def baidu(url): api = 'http://data.zz.baidu.com/urls?site=站点&token=你的token'; header = { "Content-Type": "text/plain" } re = requests.post(api,data=url) #print(re.text,end="\r",) #必要的时候记得打印看看是否提交成功 ``` ### 下面是用递归函数,查找所有相关链接 ```python def get_a(url): soup = BeautifulSoup(requests.get(url).text) for a in soup.find_all('a'): if 'href' in a.attrs: if 'blog.a152.top' in a['href']: if a['href'] not in links: links.append(a['href']) baidu(a['href']) print(a['href']) get_a(a['href']) ``` ### 最后的调用 ```python links = [] get_a('http://blog.a152.top') ``` ## 总结 可以看到,代码其实是非常简单的,主要的针对目标是链接少于1000的站长用的,我当时的blog是362多个内链,当然,其实还有很多不足的地方,希望大家能够包容一下,本身就是写的玩的,也顺便启发一下大家之类的,会多进程多线程,此处应有无限的遐想... ## 祝大家国庆快乐 顺带一提,今天是2021/10/5 3:06 Last modification:October 5, 2021 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 如果觉得我的内容对你有用,请随意赞赏