gpt4 book ai didi

python - python 中的 Curl POST 或类似方法

转载 作者:行者123 更新时间:2023-12-01 05:56:09 25 4
gpt4 key购买 nike

这可能是一个有点过于直接的问题。 Python 新手

我正在尝试从视频网站(Putlocker)解析/抓取视频链接。
http://www.putlocker.com/file/A189D40E3E612C50 .

页面最初出现时包含以下代码或类似代码

<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="3d0865fbb040e670"每次都会改变...

Import urllib
import urllib2

url = 'http://www.putlocker.com/file/A189D40E3E612C50.'
response = urllib2.urlopen(url)
page = response.read()

从这里我找到了 Value="?"哈希值

然后

url = 'http://www.putlocker.com/file/A189D40E3E612C50.'
values = {'hash' : 3d0865fbb040e670}
data = urllib.urlencode(values)
response = urllib2.urlopen(url)
page = response.read()

但我最终又回到了同一页面。我是否也发布 value="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

所以我再次返回相同的页面..我在这里做错了什么!!我见过一种叫做 pycurl 的东西..但我想使用更简单的东西..有什么线索吗??

最佳答案

urllib2.urlopen(url,data=data)

关于python - python 中的 Curl POST 或类似方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12532321/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com