iloveyby's recent timeline updates
iloveyby

iloveyby

V2EX member #79093, joined on 2014-10-29 10:56:24 +08:00
iloveyby's recent replies
同样的环境下..浏览器能打开 requests 一定能打开
将浏览器抓包, 把浏览器请求网站的 request headers 全部弄下来.添加到 requests 里
代码如下
headers = {
"user-agent'':"Mozilla xxx"
"Content-Type": "htmlxxx"
....
}
resp = requests.get(url='domain.com',headers=headers)
print(resp.status_code)
最近在学习 asyncio 和 aiohttp 的相关知识, 和 lz 共勉.
先看错误
` RuntimeError: There is no current event loop in thread 'Thread-2'`
这个说明在 thread-2 的线程中没有事件循环
asyncio 中,
先要创建一个 get_event_loop 的对象,
然后
需要生成一个类型是 list 的 tasks
最近把 tasks 放入 run 中进行循环处理

看 lz 的 run 代码
```
def run(self, name, sku, page_start, page_end, sort, price_start, price_end):
loop = asyncio.get_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(self.async_run(start_page, end_page, goods_name, rank_type, price))
```

没有发现有 tasks 的任务..感觉问题就出现在这里..
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5313 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 19ms · UTC 05:52 · PVG 13:52 · LAX 22:52 · JFK 01:52
♥ Do have faith in what you're doing.