Py学习  »  Python

Web废料python,在网站上提交搜索表单,不更改url

Rika • 6 年前 • 2403 次点击  

我想通过搜索zipcodes来提取剧院的位置,并提取结果。 网站检查是这样的:

    <form id="set-location-form" class="ip-geoloc-address" action="/theatres" method="post" accept-charset="UTF-8"><div><button class="btn btn-default form-submit" id="edit-find" name="op" value=" " type="submit"> </button>
    <input type="hidden" name="form_build_id" value="form-C5B0Dm8QYZgOzeTv2uf9FlNjWVK-EbcLpDKjRz_HQt4" />
    <input type="hidden" name="form_id" value="ip_geoloc_set_location_form" />
    <div class="form-type-textfield form-item-street-address form-item form-group">
     <input placeholder="Enter your location" class="form-control form-text" type="text" id="edit-street-address" name="street_address" value="" size="60" maxlength="128" />
    </div>
    <button class="btn btn-default form-submit" id="edit-submit-address" name="op" value="Go" type="submit">Go</button>
    <button class="change-view btn-map-expand btn btn-default form-submit" id="edit-map-expand" name="op" value="Map" type="button">Map</button>
    <button class="change-view btn btn-default form-submit" id="edit-change-view" name="op" value="" type="button"></button>

检查结果如下:

[enter image description here][1]

但当我查看页面源代码时,它并不存在:

<div class="region region-content">
<section id="block-system-main" class="block block-system clearfix">
<div class="view view-theatres view-id-theatres view-display-id-page view-dom-id-8a00da3218aaa60e6d4d49fd07033c0b wrapper-container-box">
<div class="attachment attachment-before fix-wrapper">
<div class="view view-theatres view-id-theatres view-display-id-attachment_1">
<div class="view-content">
<div class="ip-geoloc-map view-based-map">

我试过这两种密码,但没用。 导入请求

url = 'https://www.imax.com/theatres/'
data = {'street_address':'78759'}
r = requests.get(url, params=data)
with open("requests_results.html", "wb") as f:
    f.write(r.content)


data = { 'street_address':'94704'}
# Get the page
# use .post
# send the data
url = "https://www.imax.com/theatres/"
response = requests.post(url,data=data)
doc = BeautifulSoup(response.text, 'html.parser')

有人帮忙吗,谢谢!!

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/50370
文章 [ 1 ]  |  最新文章 6 年前