
python挖掘百度相关关键词 百度搜索引擎相关搜索优化推广
十几年的时间,SEO从鲜有听闻的全新概念发展成为一个热门行业。SEO从业者薪酬水涨船高,高手SEO更是炙手可热。做为一个职业的SEO,必须能够写一些小工具,这里我用python写了一个批量挖掘百度相关关键词的脚本,仅供大家参考使用,帮助SEO工作者做好百度搜索引擎相关搜索优化推广。
#coding:utf-8
#author:开拓,杭州SEO http://www.xihuseo.com/
import requests,time,re
from lxml import etree
words = open('words.txt','r').read()
words = words.split('\n')
for i in words:
print i.decode('gbk')
myfile = open('mykewords.txt','a')
for word in words:
myfile.write('\n')
word = word.replace('\n','')
word = word.decode('gbk','ignore')
url = 'http://www.baidu.com/sie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd='+ word
con = requests.get(url).content
#print con
selector = etree.HTML(con)
items = selector.xpath('//div[@id="rs"]/table/tr/th')
#print len(items)
for _ in items:
_ = _.xpath('string(.)')
_ = _.encode('gbk')
myfile.write(_+'\n')
将要查询的词放入words.txt里面,然后运行脚本,就可以批量查询关键词的相关搜索词了。下载地址:
![]() |
百度相关搜索关键词挖掘python脚本 |
更多SEO小工具,敬请关注杭州SEO中心博客,有任何问题请联系博主。
上一篇:百度收录批量查询工具 python版 下一篇:seo关键词优化软件
如果您需要帮助,可以立即拨打我们的服务热线!