python搜索关键词自动提交订单_Python批量获取淘宝相关搜索和下拉框关键词
首先淘寶seo是什么?淘寶seo是對(duì)淘寶站內(nèi)關(guān)鍵字排名進(jìn)行優(yōu)化,淘寶三大排名因數(shù):文本相關(guān)性,商業(yè)因素,用戶喜好度。非專業(yè)總結(jié)(勿噴)
1,文本相關(guān)性:起碼標(biāo)題出現(xiàn)吧
2,商業(yè)因素:廣告展位,直通車等
3,用戶喜好度:成交量,評(píng)論系統(tǒng),旺旺等等
其實(shí)做百度SEO完全可以從淘寶挖掘關(guān)鍵字來(lái)使用,萬(wàn)一客戶在百度搜索呢,,我們可以找多一些詞根,長(zhǎng)尾也沒(méi)關(guān)系,去爆淘寶或一些電子商務(wù)平臺(tái)的關(guān)鍵字
下面我的腳本也比較簡(jiǎn)單,不過(guò)這次又稍微用到面向?qū)ο缶幊?#xff0c;思路也跟市面上的差不多,抓包發(fā)現(xiàn)淘寶API接口,用requests,urllib等模塊爆它,出來(lái)一些數(shù)據(jù),然后提取就是了。
另外說(shuō)說(shuō)chardet和multiprocessing模塊,如果不是自帶的就用“pip install 庫(kù)名字”安裝就是;chardet計(jì)算那個(gè)編碼的,multiprocessing是多進(jìn)程,百度一下,你就知道!
然后程序?qū)懙暮脝?#xff0c;主要是順便練練手而已
下面篼雨seo博客啰里啰嗦寫(xiě)的淘寶seo查詢工具:批量獲取相關(guān)搜索和下拉框關(guān)鍵詞:
#encoding=utf-8
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
import urllib
import requests
import re
import json
import chardet
import multiprocessing
# print 'hello world'
# keyword=raw_input('請(qǐng)輸入關(guān)鍵字:'.decode('utf-8').encode('gbk'))
class taobaospider(multiprocessing.Process):
def __int__(self):
multiprocessing.Process.__int__(self)
def words(self):
for line in open('word.txt'):
keyword=line.strip()
self.taobao(keyword)
self.staobao(keyword)
def taobao(self,keyword):
self.op_txt=open('sword.txt','a')
url='https://suggest.taobao.com/sug?code=utf-8&q=%s&_ksTS=1388978237516_3338&callback=jsonp3339&k=1&area=c2c&bucketid=11'%urllib.quote_plus(keyword)
html=requests.get(url=url,timeout=10).content
# print html
data=re.compile(r'\((.+?)\)')
jsdata=re.findall(data,html)
for i in jsdata:
c=json.loads(i)
a=c['result']
for n in a:
self.op_txt.write('%s\n'%n[0])
print n[0]
def staobao(self,keyword):
url='https://s.taobao.com/search?q='+keyword+''
headers={'host':'s.taobao.com','user-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36'}
page=requests.post(url=url,headers=headers,timeout=10).content
# page=html.decode('utf-8')
c=re.compile(r'"text":"(.+?)","isHighlight":false,"href":"/search\?q.+?"}')
a=re.findall(c,page)
for i in a:
mychar = chardet.detect(i)
# print mychar
bianma = mychar['encoding']
print bianma
if bianma == 'utf-8' or bianma == 'UTF-8':
data=i
self.op_txt.write('%s\n'%data)
print data
else:
data=i.decode('gbk').encode('utf-8')
self.op_txt.write('%s\n'%data)
print data
if __name__ == '__main__':
p=taobaospider()
p.words()
p.start()
總結(jié)
以上是生活随笔為你收集整理的python搜索关键词自动提交订单_Python批量获取淘宝相关搜索和下拉框关键词的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python编程怎么建立工程_教你如何用
- 下一篇: qpython3安装lxml_cento