Python 2.7 如何在python请求中使用Splash?
我想用splash-in,类似这样的东西Python 2.7 如何在python请求中使用Splash?,python-2.7,scrapy,python-requests,splash-screen,scrapyjs,Python 2.7,Scrapy,Python Requests,Splash Screen,Scrapyjs,我想用splash-in,类似这样的东西 requests.post(myUrl,headers=myHeaders, data=payload, meta={ 'splash': { 'endpoint': 'render.html', 'a
requests.post(myUrl,headers=myHeaders, data=payload, meta={
'splash': {
'endpoint': 'render.html',
'args': {'wait': 1}
}
})
但我有这个错误
TypeError: request() got an unexpected keyword argument 'meta'
我知道这与scrapy.Request一起工作,但我想与
meta
一起使用,它是特定于scrapyRequest
的,并且没有meta
参数,因此出现了TypeError
异常
要在python请求中使用Splash,请阅读,因为这似乎是您想要使用的
您需要一个对/render.html
端点的GET请求,并将目标URL和wait
参数作为查询参数传递,例如:
import requests
requests.get('http://localhost:8050/render.html',
params={'url': 'http://www.example.com', 'wait': 2})
如果希望Splash向目标网站发出POST请求,请使用http\u方法
和body
参数:
import requests
requests.get('http://localhost:8050/render.html',
params={'url': 'http://httpbin.org/post',
'http_method': 'POST',
'body': 'a=b',
'wait': 2})
/render.html
另外:
飞溅是通过HTTP API控制的。对于所有端点,以下参数可以作为GET参数发送,也可以编码为JSON,并使用内容类型:application/JSON
标题发布
但是默认方法仍然是GET。要向目标网站发布帖子,您仍然需要包含http\u方法
参数:
import requests
requests.post('http://localhost:8050/render.html',
json={'url': 'http://httpbin.org/post',
'http_method': 'POST',
'body': 'a=b',
'wait': 2})
但是我应该发送一个发帖请求你的意思是Splash应该向目标网站发出发帖请求吗?如果是,则有可用的
/render.html
我需要在min my requests POST中设置“WAIT”