8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

无法生成包含我希望获取的地址的结果

Shawn Dillon 2月前

16 0

我正在尝试使用此网站的请求模块和 BeautifulSoup 库创建一个脚本,该脚本将执行以下操作:选择 Strata 计划编号按钮,在输入框中输入 11,......

网站 的请求模块和 BeautifulSoup 库创建一个脚本, 该脚本将执行以下操作:

选择 Strata 计划编号 按钮,在输入框中输入 11 ,然后点击 搜索 按钮。最后从结果中抓取地址。

运行脚本后,当我验证结果时,我没有看到其中的地址。

import re
import requests
from bs4 import BeautifulSoup

link = 'https://www.nsw.gov.au/housing-and-construction/strata/strata-search'
url = 'https://www.stratahub.nsw.gov.au/prweb/PRAuth/app/ssr_4380/6nxCgYjOTS_fVOVfeekVPA*/!SchemeSearch?pzTransactionId=cc5ddc1ecec1c095231675db14450f87&pzFromFrame=&pzPrimaryPageName=pyDisplayHarness&AJAXTrackID=22'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
    'accept': '*/*',
    'accept-encoding': 'gzip, deflate, br, zstd',
    'accept-language': 'en-US,en;q=0.9',
    'X-Requested-With': 'XMLHttpRequest',
    'origin': 'https://www.stratahub.nsw.gov.au',
}

payload = {
    "$PSchemeSearch$pSearchBy": "Strata Plan Number",
    "$PSchemeSearch$pSchemePlanNumber": 11,
    "pzuiactionzzz": "",
    "PreActivitiesList": "",
    "sectionParam": "",
    "ActivityParams": "=",
    "$ODesktopWrapperInclude": "",
    "$ODeterminePortalTop": "",
    "$ODynamicLayout": "",
    "$ODynamicLayoutCell": "",
    "$OEvalDOMScripts_Include": "",
    "$OForm": "",
    "$OHarness": "",
    "$OHarnessStaticJSEnd": "",
    "$OHarnessStaticJSStart": "",
    "$OHarnessStaticScriptsClientValidation": "",
    "$OPMCHarnessStaticScripts": "",
    "$OSessionUser": "",
    "$OSurveyStaticScripts": "",
    "$OWorkformStyles": "",
    "$OpxAutoComplete": "",
    "$OpxButton": "",
    "$OpxDisplayText": "",
    "$OpxHarnessContent": "",
    "$OpxLayoutContainer": "",
    "$OpxNonTemplate": "",
    "$OpxRadioButtons": "",
    "$OpxSection": "",
    "$OpxVisible": "",
    "$OpxWorkArea": "",
    "$OpxWorkAreaContent": "",
    "$OpyDirtyCheckConfirm": "",
    "$OpyWorkFormStandardEnd": "",
    "$OpyWorkFormStandardStart": "",
    "$OpzAutoCompleteAGIncludes": "",
    "$OpzHarnessInlineScriptsEnd": "",
    "$OpzHarnessInlineScriptsStart": "",
    "$OpzPortalFavIcon": "",
    "$OpzPortalIcon": "",
    "$Opzpega_ui_harnesscontext": "",
    "$Opzpega_web_mashup": "",
    "$OpxTextInput": "",
    "$OpzDecimalInclude": "",
    "pyEncodedParameters": True,
    "pzKeepPageMessages": False,
    "strPHarnessClass": "Data-Portal",
    "strPHarnessPurpose": "SearchStrataScheme",
    "UITemplatingStatus": "Y",
    "StreamName": "SchemeSearch",
    "BaseReference": "SchemeSearch",
    "bClientValidation": True,
    "FormError": "NONE",
    "pyCustomError": "DisplayErrors",
    "UsingPage": True,
    "HeaderButtonSectionName": "-1",
    "PagesToRemove": "",
    "pzHarnessID": "HID387D2E2FCEE4EC200B5BAEA8C6A5D859",
    "inStandardsMode": True
}



with requests.Session() as s:
    s.headers.update(headers)
    res = s.get(link)
    soup = BeautifulSoup(res.text,"lxml")
    code_url = soup.select_one("iframe[title='Strata Search Production']")['data-src']
    s.headers['referer'] = code_url
    payload['pzuiactionzzz'] = code_url.split("?")[-1]
    r = s.post(url,data=payload)
    print(r.status_code)
    print(r.text)

我如何才能生成包含我想要的地址的结果?

帖子版权声明 1、本帖标题:无法生成包含我希望获取的地址的结果
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由Shawn Dillon在本站《python》版块原创发布, 转载请注明出处!
最新回复 (0)
返回
作者最近主题: