连干10天,完成这款seo工具集合
优采云 发布时间: 2022-07-22 14:04连干10天,完成这款seo工具集合
搜狗快照反馈,原理一样,同样是拿到接口就可以,不过搜狗快照反馈是不需要登录的,只需要验证一下验证码就可以。
同样在代码里,将请求参数进行复原。
1<br style="box-sizing: border-box;" />2<br style="box-sizing: border-box;" />3<br style="box-sizing: border-box;" />4<br style="box-sizing: border-box;" />5<br style="box-sizing: border-box;" />6<br style="box-sizing: border-box;" />7<br style="box-sizing: border-box;" />8<br style="box-sizing: border-box;" />9<br style="box-sizing: border-box;" />10<br style="box-sizing: border-box;" />11<br style="box-sizing: border-box;" />12<br style="box-sizing: border-box;" />13<br style="box-sizing: border-box;" />14<br style="box-sizing: border-box;" />15<br style="box-sizing: border-box;" />
def fankui_sougou(self,url,email):<br style="box-sizing: border-box;" /> # while True:<br style="box-sizing: border-box;" /> multipart_encoder = MultipartEncoder(<br style="box-sizing: border-box;" /> fields = {<br style="box-sizing: border-box;" /> 'KuaizhaoUpdate[webAdr][]':url,<br style="box-sizing: border-box;" /> 'KuaizhaoUpdate[contact]':email,<br style="box-sizing: border-box;" /> 'webContactWayTypeForm2':'邮箱',<br style="box-sizing: border-box;" /> 'jsVcodeForm2':self.code<br style="box-sizing: border-box;" /> }<br style="box-sizing: border-box;" /> )<br style="box-sizing: border-box;" /> <br style="box-sizing: border-box;" /> self.headers['Content-Type'] = multipart_encoder.content_type<br style="box-sizing: border-box;" /> self.headers['accept'] = 'application/json'<br style="box-sizing: border-box;" /> resp = self.session.post(url=self.fankui_url,data=multipart_encoder,headers=self.headers).json()<br style="box-sizing: border-box;" /> return resp<br style="box-sizing: border-box;" />
三、百度关键词排名查询
百度关键词排名查询,查询原理主要是解析百度页面,获取目标网站的排名即可,查询过程中,偶尔会出现不稳定的情况,这个需要配合请求代理使用。只要少量查询是没有问题的。
1<br style="box-sizing: border-box;" />2<br style="box-sizing: border-box;" />3<br style="box-sizing: border-box;" />4<br style="box-sizing: border-box;" />5<br style="box-sizing: border-box;" />6<br style="box-sizing: border-box;" />7<br style="box-sizing: border-box;" />8<br style="box-sizing: border-box;" />9<br style="box-sizing: border-box;" />10<br style="box-sizing: border-box;" />11<br style="box-sizing: border-box;" />12<br style="box-sizing: border-box;" />13<br style="box-sizing: border-box;" />14<br style="box-sizing: border-box;" />15<br style="box-sizing: border-box;" />16<br style="box-sizing: border-box;" />17<br style="box-sizing: border-box;" />18<br style="box-sizing: border-box;" />19<br style="box-sizing: border-box;" />20<br style="box-sizing: border-box;" />21<br style="box-sizing: border-box;" />22<br style="box-sizing: border-box;" />23<br style="box-sizing: border-box;" />24<br style="box-sizing: border-box;" />25<br style="box-sizing: border-box;" />26<br style="box-sizing: border-box;" />27<br style="box-sizing: border-box;" />28<br style="box-sizing: border-box;" />29<br style="box-sizing: border-box;" />30<br style="box-sizing: border-box;" />31<br style="box-sizing: border-box;" />32<br style="box-sizing: border-box;" />33<br style="box-sizing: border-box;" />
def spider_html(self, url):<br style="box-sizing: border-box;" /> proxy = 't15033843606481:ucxt8q6k@tps543.kdlapi.com:15818'<br style="box-sizing: border-box;" /> while True:<br style="box-sizing: border-box;" /> try:<br style="box-sizing: border-box;" /> proxies = {<br style="box-sizing: border-box;" /> 'http': 'http://' + proxy,<br style="box-sizing: border-box;" /> 'https': 'http://' + proxy<br style="box-sizing: border-box;" /> }<br style="box-sizing: border-box;" /> self.session.get(url=self.m_base_url,<br style="box-sizing: border-box;" /> headers=headers,<br style="box-sizing: border-box;" /> proxies=proxies)<br style="box-sizing: border-box;" /> break<br style="box-sizing: border-box;" /> except:<br style="box-sizing: border-box;" /> continue<br style="box-sizing: border-box;" /> resp = self.session.get(url=url, headers=headers, verify=False)<br style="box-sizing: border-box;" /> resp.encoding = resp.apparent_encoding<br style="box-sizing: border-box;" /> # print(resp.text)<br style="box-sizing: border-box;" /> print(resp.status_code)<br style="box-sizing: border-box;" /> while 'wappass' in resp.url:<br style="box-sizing: border-box;" /> print('出现验证码了', resp.url)<br style="box-sizing: border-box;" /> rand_ip = self.rand_ip()<br style="box-sizing: border-box;" /> url = url.replace(urlparse(url).netloc, rand_ip)<br style="box-sizing: border-box;" /> try:<br style="box-sizing: border-box;" /> resp = self.session.get(url=url,<br style="box-sizing: border-box;" /> headers=headers,<br style="box-sizing: border-box;" /> proxies=proxies,<br style="box-sizing: border-box;" /> verify=False)<br style="box-sizing: border-box;" /> except:<br style="box-sizing: border-box;" /> continue<br style="box-sizing: border-box;" /> else:<br style="box-sizing: border-box;" /> if not 'wappass' in resp.url:<br style="box-sizing: border-box;" /> return resp.text<br style="box-sizing: border-box;" /><br style="box-sizing: border-box;" />
四、百度主动推送
百度主动推送还是比较简单的,只要在百度站长平台拿到接口地址就可以模拟post请求了。
在代码里,请求部分,可以这么操作
1<br style="box-sizing: border-box;" />2<br style="box-sizing: border-box;" />3<br style="box-sizing: border-box;" />4<br style="box-sizing: border-box;" />5<br style="box-sizing: border-box;" />6<br style="box-sizing: border-box;" />7<br style="box-sizing: border-box;" />8<br style="box-sizing: border-box;" />9<br style="box-sizing: border-box;" />10<br style="box-sizing: border-box;" />11<br style="box-sizing: border-box;" />12<br style="box-sizing: border-box;" />13<br style="box-sizing: border-box;" />14<br style="box-sizing: border-box;" />15<br style="box-sizing: border-box;" />16<br style="box-sizing: border-box;" />17<br style="box-sizing: border-box;" />18<br style="box-sizing: border-box;" />19<br style="box-sizing: border-box;" />20<br style="box-sizing: border-box;" />21<br style="box-sizing: border-box;" />22<br style="box-sizing: border-box;" />
def badiu_tuisong(token,site,data):<br style="box-sizing: border-box;" /> url = f'http://data.zz.baidu.com/urls?site={site}&token={token}'<br style="box-sizing: border-box;" /> # data = '\n'.join(open('urls.txt','r').read().splitlines())<br style="box-sizing: border-box;" /><br style="box-sizing: border-box;" /> headers = {<br style="box-sizing: border-box;" /> 'Content-Type': 'text/plain',<br style="box-sizing: border-box;" /> }<br style="box-sizing: border-box;" /> result = requests.post(url=url,data=data,headers=headers).json()<br style="box-sizing: border-box;" /> # request = urllib.request.Request(url=url,data=bytes(data,encoding='utf-8'),headers=headers)<br style="box-sizing: border-box;" /> # resp = urllib.request.urlopen(request)<br style="box-sizing: border-box;" /> # result = eval(resp.read().decode())<br style="box-sizing: border-box;" /> # result.update({'url':site})<br style="box-sizing: border-box;" /> try:<br style="box-sizing: border-box;" /> if result['success']:<br style="box-sizing: border-box;" /> return result<br style="box-sizing: border-box;" /> else:<br style="box-sizing: border-box;" /> del result['success']<br style="box-sizing: border-box;" /> del result['not_same_site']<br style="box-sizing: border-box;" /> result.update({'fail':0})<br style="box-sizing: border-box;" /> return result<br style="box-sizing: border-box;" /> except:<br style="box-sizing: border-box;" /> return result<br style="box-sizing: border-box;" />
五、搜狗关键词排名
搜狗关键词排名原理同样的解析页面,通过页面拿到目标网站的排名
1<br style="box-sizing: border-box;" />2<br style="box-sizing: border-box;" />3<br style="box-sizing: border-box;" />4<br style="box-sizing: border-box;" />5<br style="box-sizing: border-box;" />6<br style="box-sizing: border-box;" />7<br style="box-sizing: border-box;" />8<br style="box-sizing: border-box;" />9<br style="box-sizing: border-box;" />10<br style="box-sizing: border-box;" />11<br style="box-sizing: border-box;" />12<br style="box-sizing: border-box;" />13<br style="box-sizing: border-box;" />14<br style="box-sizing: border-box;" />15<br style="box-sizing: border-box;" />16<br style="box-sizing: border-box;" />17<br style="box-sizing: border-box;" />18<br style="box-sizing: border-box;" />19<br style="box-sizing: border-box;" />20<br style="box-sizing: border-box;" />21<br style="box-sizing: border-box;" />22<br style="box-sizing: border-box;" />23<br style="box-sizing: border-box;" />24<br style="box-sizing: border-box;" />25<br style="box-sizing: border-box;" />26<br style="box-sizing: border-box;" />27<br style="box-sizing: border-box;" />28<br style="box-sizing: border-box;" />29<br style="box-sizing: border-box;" />30<br style="box-sizing: border-box;" />31<br style="box-sizing: border-box;" />
def spider_html(self,url):<br style="box-sizing: border-box;" /> self.session.get(url=self.vsogou_url)<br style="box-sizing: border-box;" /> try:<br style="box-sizing: border-box;" /> rand_headers = Headers(headers=True).generate()<br style="box-sizing: border-box;" /> headers = {<br style="box-sizing: border-box;" /> 'User-Agent':rand_headers['User-Agent'],<br style="box-sizing: border-box;" /> }<br style="box-sizing: border-box;" /> resp = self.session.get(url=url,headers=headers)<br style="box-sizing: border-box;" /> resp.encoding = resp.apparent_encoding<br style="box-sizing: border-box;" /> # print(resp.text)<br style="box-sizing: border-box;" /> return resp.text<br style="box-sizing: border-box;" /> except Exception as e:<br style="box-sizing: border-box;" /> print(e)<br style="box-sizing: border-box;" /> <br style="box-sizing: border-box;" /> def parse_html(self,html):<br style="box-sizing: border-box;" /> e_obj = etree.HTML(html)<br style="box-sizing: border-box;" /> divs = e_obj.xpath("//div[@id='main']//div[@class='vrwrap']")<br style="box-sizing: border-box;" /> # print(divs)<br style="box-sizing: border-box;" /> for index,div in enumerate(divs):<br style="box-sizing: border-box;" /> i = div.xpath("./div[@class='citeurl']/i")<br style="box-sizing: border-box;" /> if i:<br style="box-sizing: border-box;" /> yu_name = div.xpath("./div[@class='citeurl']/span[2]/text() | .//div[contains(@class,'citeurl')]/span[1]/text()")<br style="box-sizing: border-box;" /> # print(yu_name)<br style="box-sizing: border-box;" /> else:<br style="box-sizing: border-box;" /> yu_name = div.xpath("./div[@class='citeurl']/span[1]/text() | .//div[contains(@class,'citeurl')]/span[1]/text()")<br style="box-sizing: border-box;" /> # print(yu_name)<br style="box-sizing: border-box;" /> if yu_name:<br style="box-sizing: border-box;" /> if self.web_name in yu_name[0]:<br style="box-sizing: border-box;" /> ranking = index + 1 if index == 0 else index<br style="box-sizing: border-box;" /> return ranking<br style="box-sizing: border-box;" /><br style="box-sizing: border-box;" />
六、搜狗移动关键词排名
搜狗移动关键词排名解析的是搜狗移动端的页面,然后获取排名信息即可,不过代码解析部分和pc端的不一样
1<br style="box-sizing: border-box;" />2<br style="box-sizing: border-box;" />3<br style="box-sizing: border-box;" />4<br style="box-sizing: border-box;" />5<br style="box-sizing: border-box;" />6<br style="box-sizing: border-box;" />7<br style="box-sizing: border-box;" />8<br style="box-sizing: border-box;" />9<br style="box-sizing: border-box;" />10<br style="box-sizing: border-box;" />11<br style="box-sizing: border-box;" />12<br style="box-sizing: border-box;" />13<br style="box-sizing: border-box;" />14<br style="box-sizing: border-box;" />15<br style="box-sizing: border-box;" />16<br style="box-sizing: border-box;" />17<br style="box-sizing: border-box;" />18<br style="box-sizing: border-box;" />19<br style="box-sizing: border-box;" />20<br style="box-sizing: border-box;" />21<br style="box-sizing: border-box;" />22<br style="box-sizing: border-box;" />23<br style="box-sizing: border-box;" />24<br style="box-sizing: border-box;" />25<br style="box-sizing: border-box;" />26<br style="box-sizing: border-box;" />27<br style="box-sizing: border-box;" />28<br style="box-sizing: border-box;" />29<br style="box-sizing: border-box;" />30<br style="box-sizing: border-box;" />
def spider_html(self, url):<br style="box-sizing: border-box;" /> self.session.get(url=self.vsogou_url)<br style="box-sizing: border-box;" /> try:<br style="box-sizing: border-box;" /> rand_headers = Headers(headers=True).generate()<br style="box-sizing: border-box;" /> headers = {<br style="box-sizing: border-box;" /> 'User-Agent': rand_headers['User-Agent'],<br style="box-sizing: border-box;" /> }<br style="box-sizing: border-box;" /> resp = self.session.get(url=url, headers=headers)<br style="box-sizing: border-box;" /> resp.encoding = resp.apparent_encoding<br style="box-sizing: border-box;" /> # print(resp.text)<br style="box-sizing: border-box;" /> return resp.text<br style="box-sizing: border-box;" /> except Exception as e:<br style="box-sizing: border-box;" /> print(e)<br style="box-sizing: border-box;" /><br style="box-sizing: border-box;" /> def parse_html(self, html):<br style="box-sizing: border-box;" /> # print(html)<br style="box-sizing: border-box;" /> soup = BeautifulSoup(html, 'lxml')<br style="box-sizing: border-box;" /> divs = soup.select("body div.vrResult")<br style="box-sizing: border-box;" /><br style="box-sizing: border-box;" /> for div in divs:<br style="box-sizing: border-box;" /> if not div: continue<br style="box-sizing: border-box;" /> item = div.select(".citeurl span")<br style="box-sizing: border-box;" /> if not item: continue<br style="box-sizing: border-box;" /> try:<br style="box-sizing: border-box;" /> item = item[0].get_text()<br style="box-sizing: border-box;" /> except:<br style="box-sizing: border-box;" /> item = item[1].get_text()<br style="box-sizing: border-box;" /> if self.web_name in item:<br style="box-sizing: border-box;" /> ranking = re.sub(r'.*_', '', div.attrs['id'])<br style="box-sizing: border-box;" /> return ranking<br style="box-sizing: border-box;" />
七、百度下拉词获取
百度下拉词获取调用的下拉词的接口,
在代码里,不断测试获取有用的参数,最终在代码里只需要两个参数就可以了
1<br style="box-sizing: border-box;" />2<br style="box-sizing: border-box;" />3<br style="box-sizing: border-box;" />4<br style="box-sizing: border-box;" />5<br style="box-sizing: border-box;" />6<br style="box-sizing: border-box;" />7<br style="box-sizing: border-box;" />8<br style="box-sizing: border-box;" />9<br style="box-sizing: border-box;" />10<br style="box-sizing: border-box;" />11<br style="box-sizing: border-box;" />12<br style="box-sizing: border-box;" />13<br style="box-sizing: border-box;" />14<br style="box-sizing: border-box;" />15<br style="box-sizing: border-box;" />16<br style="box-sizing: border-box;" />
def getXialaci(self,keyword):<br style="box-sizing: border-box;" /> url = 'https://www.baidu.com/sugrec'<br style="box-sizing: border-box;" /> params = {<br style="box-sizing: border-box;" /> 'prod': 'pc',<br style="box-sizing: border-box;" /> 'wd': keyword,<br style="box-sizing: border-box;" /> }<br style="box-sizing: border-box;" /> try:<br style="box-sizing: border-box;" /> res = requests.get(url,params=params,timeout=5).json()<br style="box-sizing: border-box;" /> except:<br style="box-sizing: border-box;" /> pass<br style="box-sizing: border-box;" /> # print(json.dumps(res,indent=4,ensure_ascii=False))<br style="box-sizing: border-box;" /> else:<br style="box-sizing: border-box;" /> if res.get('g',''):<br style="box-sizing: border-box;" /> keywords = [keyword['q'] for keyword in res['g']]<br style="box-sizing: border-box;" /> print(keywords)<br style="box-sizing: border-box;" /> return keywords<br style="box-sizing: border-box;" />
下面视频介绍简单了解一下:
软件的总体原理就这样了,有其他疑问的地方或者需要使用这款集合软件,另外后面会继续新增功能,有需要的朋友可以定制,可以私信我!vx:dan_moln