python关键词排名批量查排名_Python批量查询阿里国际站关键词排名工具

#encoding=utf-8

import urllib

import re

import threading

import requests

import time

def get_ranK(b):

url='https://www.alibaba.com/products/'+b+'.html'

url01='https://www.alibaba.com/products/'+b+'/2.html'

url02='https://www.alibaba.com/products/'+b+'/3.html'

html=requests.get(url=url).content

html01=requests.get(url=url01).content

html02=requests.get(url=url02).content

company=re.compile(r'

if "https://gzxibolai.en.alibaba.com" in html:

page=re.findall(company,html)

for x in page:

print b,u'约第1页%s位\n'%x

op_paiming_txt.writelines("%s,约第1页%s位\n"%(b,x))

time.sleep(2)

return

elif "https://gzxibolai.en.alibaba.com" in html01:

page01=re.findall(company,html01)

for m in page01:

print b,u'约第2页%s位\n'%m

op_paiming_txt.writelines("%s,约第2页%s位\n"%(b,m))

time.sleep(2)

return

elif "https://gzxibolai.en.alibaba.com" in html02:

page02=re.findall(company,html02)

for o in page02:

print b,u'约第3页%s位\n'%o

op_paiming_txt.writelines("%s,约第3页%s位\n"%(b,o))

time.sleep(2)

return

else:

print b,u'前3页无排名\n'

op_paiming_txt.writelines("%s,前3页无排名\n"%b)

time.sleep(2)

return

# if __name__ == '__main__':

# with open('kfc.txt','r') as c:

# for i in c.readlines():

# f=i.strip()

# get_ranK(f)

if __name__ == '__main__':

with open('kfc.txt','r') as c:

for i in c.readlines():

f=i.strip()

threading.Lock()

p=threading.Thread(target=get_ranK,args=(f,))

p.start()

op_paiming_txt=open('paiming.csv','a')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值