|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我想如果我写线程,开十个线程拿到的以下代码for qqq in range(607,1415):中的值都是一样的,那样我开不开线程的意义就不大了,我需要让第一个拿到这个线程的线程传入两个值来代替这个for中的两个值,我应该如何去做
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
from lxml import etree
import requests
import time
import xlwt
import datetime
import re
for qqq in range(607,1415):
nows = datetime.datetime.now()
print(str(qqq), '-----', str(nows.strftime("%H.%M")))
params = {
'pageindex': qqq,
'pagesize': '1',
'corpname': '',
'corpcode': '',
'sfswqy': '0',
'certtypenum': '2',
'danweitype': ''
}
head_link = 'http://hbjz.hbcic.net.cn/hbythqy/szjs_ythpt/frame/workportal/djgcompanyinfotempaction_yth.action?cmd=getCorpInfoList'
try:
response = requests.post(url=head_link, params=params,timeout=50)
except (requests.exceptions.RequestException, ValueError):
response = requests.post(url=head_link, params=params,timeout=50)
s = response.text.encode('GB18030').decode('unicode_escape')
# 如果是json的话,转化为json
json1 = json.loads(s, strict=False)
results = json1.get('custom')
resultss = results.get('list')
for i in resultss:
danweiname = i.get('danweiname')
farenname = i.get('farenname')
dwtypename = i.get('dwtypename')
qyrowguid = i.get('qyrowguid')
socialcode = i.get('socialcode')
非常感谢
|
|