在发布或获取请求时,我们如何使用URL传递数据?

发布于 2025-02-12 06:23:58 字数 1627 浏览 0 评论 0原文

URL - http://164.100.47.193/Loksabha/Legislation/billintroduce.aspx

So 我想传递突出显示的数据,并想刮擦我得到的结果。就像您在图像总共有13张账单,我需要刮擦的那些账单。

我拥有dificulty的区域是,当我尝试执行帖子请求时,一切似乎都很好(我的状态200),但是当我打印文本html时,似乎确实会更改任何标签例如,应检查“两个”单选按钮,但已将其检查是否默认。

一些屏幕截图可能会有所帮助。 1 2 3

这就是我正在使用的。

url = "http://164.100.47.193/Loksabha/Legislation/billintroduce.aspx"
r = requests.get(url)

我检查了网络选项卡并从那里获得了有效载荷信息,单击此信息以查看网络的有效载荷信息。

payload = {
    'ctl00$ContentPlaceHolder1$RadioBttnhouse': 'both',
    'ctl00$ContentPlaceHolder1$RadioBttnbilltyp': 'Government',
    'ctl00$ContentPlaceHolder1$ddlMinistry' : 'EXTERNAL AFFAIRS',
    'ctl00$ContentPlaceHolder1$ddlCategory' : 'Ordinary Bill',
    'ctl00$ContentPlaceHolder1$ddlYear1' : '2000',
    'ctl00$ContentPlaceHolder1$ddlYear2' : '2020',
    'ctl00$ContentPlaceHolder1$btnsbmt' : 'Submit'
}

req = requests.post(r.url, params = payload) #also tried get instead of post
req.status_code

#Output: 200

print(req.text)

在打印文本后,在HTML结果中,我看不到我刚传递的数据。

URL - http://164.100.47.193/Loksabha/Legislation/billintroduce.aspx

So I want to pass the highlighted data, and want to scrape the result I got. Like you see in the image there is a total of 13 bills, those bills I need to scrape.

The area where I'm having dificulty is, when I'm trying to do a post request everything seems fine status-wise (I got 200 in status) but when I print the text HTML it does seem to change any of the tags like for example "Both" radio button should be checked but instead it's checked for default.

Some screenshots that might be helpful.
1, 2, 3

Here's what I'm working with.

url = "http://164.100.47.193/Loksabha/Legislation/billintroduce.aspx"
r = requests.get(url)

I checked the Network tab and got the payload info from there, click this to see the payload info of the web.

payload = {
    'ctl00$ContentPlaceHolder1$RadioBttnhouse': 'both',
    'ctl00$ContentPlaceHolder1$RadioBttnbilltyp': 'Government',
    'ctl00$ContentPlaceHolder1$ddlMinistry' : 'EXTERNAL AFFAIRS',
    'ctl00$ContentPlaceHolder1$ddlCategory' : 'Ordinary Bill',
    'ctl00$ContentPlaceHolder1$ddlYear1' : '2000',
    'ctl00$ContentPlaceHolder1$ddlYear2' : '2020',
    'ctl00$ContentPlaceHolder1$btnsbmt' : 'Submit'
}

req = requests.post(r.url, params = payload) #also tried get instead of post
req.status_code

#Output: 200

print(req.text)

After printing the text, in the HTML result, I'm not able to see the data I just passed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文