python或类似方法中的curlpost

python或类似方法中的curlpost,python,curl,post,urllib2,Python,Curl,Post,Urllib2,这个问题可能有点太直接了。Python新手 我正在尝试从视频网站(Putlocker)解析/刮取视频链接。 艾 页面最初会显示以下代码或类似代码 <form method="post"> <input type="hidden" value="3d0865fbb040e670" name="hash"> <input name="confirm" type="submit" value="Continue as Free User" disabled="disab

这个问题可能有点太直接了。Python新手

我正在尝试从视频网站(Putlocker)解析/刮取视频链接。

页面最初会显示以下代码或类似代码

<form method="post">
<input type="hidden" value="3d0865fbb040e670" name="hash">
<input name="confirm" type="submit" value="Continue as Free User" 
disabled="disabled"  
 id="submitButton" class="confirm_button" style="width:190px;">
</form>
从这里我找到散列的值=“?”

然后

但我又回到了同一页。我是否也发布value=“继续作为免费用户”? 如何继续发布这两个数据

一个工作代码会很有帮助。 我正在努力,但还没有成功

好的,在几个程序员的建议之后

我试过下面的代码

url = 'http://www.putlocker.com/file/A189D40E3E612C50'
response = urllib2.urlopen(url)
html = response.read()
r = re.search('value="([0-9a-f]+?)" name="hash"', html)
session_hash = r.group(1)
print session_hash
form_values = {} 
form_values['hash'] = session_hash
form_values['confirm'] = 'Continue as Free User'
data = urllib.urlencode(form_values)
response = urllib2.urlopen(url, data=data) 
html = response.read()
print html

所以我又回到了同一页…我做错了什么!!我见过一个叫pycurl的东西。但是我想用一个更简单的东西。有什么线索吗???

你需要给
urlopen
命令指定你的编码
参数:

response = urllib2.urlopen(url, data)

否则,您将创建另一个GET请求,而不是发布。

只是为了澄清,您正在成功获取隐藏哈希的值,您的问题是如何发送HTTP POST请求而不是HTTP GET,对吗?是的,只是发布…将检查othersOk的建议。我尝试了response=urllib2.urlopen(url,数据)…相同的结果..相同的页面返回。。还有另一个输入…如何发布此按钮并一起发布哈希?请参见该按钮上的
名称
属性?将这些添加到您的
字典:
{'hash':'3d0865fbb040e670','confirm':'Continue as Free User'}
。我也尝试过了……请检查我的第二次尝试代码是否正确?我错过了什么@阿布哈斯纳特:你的代码看起来不错;问题在于你试图愚弄的网站接受了你的帖子。他们的脚本检测正在阻止您完成此任务。
url = 'http://www.putlocker.com/file/A189D40E3E612C50'
response = urllib2.urlopen(url)
html = response.read()
r = re.search('value="([0-9a-f]+?)" name="hash"', html)
session_hash = r.group(1)
print session_hash
form_values = {} 
form_values['hash'] = session_hash
form_values['confirm'] = 'Continue as Free User'
data = urllib.urlencode(form_values)
response = urllib2.urlopen(url, data=data) 
html = response.read()
print html
response = urllib2.urlopen(url, data)