在实际应用中,经由过程proxyProvider.pick()选择代劳,然后应用。如不雅代劳出现任何问题,则直接用proxy.fatal_error()降低评分,如许后续就不会选择到这个代劳了。
- def request(self, headers, payload, args, url):
- while True:
- proxy = self.proxyProvider.pick()
- try:
- response = requests.request(
- "POST", url, data=http://developer.51cto.com/art/201712/payload, headers=headers,
- proxies={"https": proxy.url},
- timeout=5,verify=False
- )
- with self.lock:
- with sqlite3.connect(self.db_name) as c:
- try:
- print(response.text)
- decoded = ujson.decode(response.text)['object']
- self.done += 1
- for x in decoded:
- c.execute("INSERT INTO mobike VALUES (%d,'%s',%d,%d,%s,%s,%f,%f)" % (
推荐阅读
云端定价比较:AWS、Microsoft Azure、Google Cloud、IBM Cloud之间的对决
开辟者大年夜赛路演 | 12月16日,技巧立异,北京不见不散因为重要的云供给商(AWS、Azure、谷歌和IBM)的云实例价格的持续降低,是以它们增长了扣头选项、增长了实例,并在某些情况下将计费增量降到了按秒>>>详细阅读
本文标题:我是怎样爬下6万共享单车数据并进行分析的(附代码)
地址:http://www.17bianji.com/lsqh/39482.html
1/2 1