执行某些步骤后无法获取从网页动态填充的号码

我使用 requests 模块和 BeautifulSoup 库创建了一个脚本来从网页中获取一些表格内容。要生成该表,必须手动按照我在所附图片中显示的步骤进行操作。我在下面粘贴的代码是一个有效的代码,但我试图解决的主要问题是以title编程方式获取数字,在本例中,628086906该数字附加到table_link我在此处硬编码的代码。

单击第 6 步中的工具按钮后,当您将光标悬停在地图上时,您可以看到此选项,Multiple当您单击该选项时,您将转到包含标题编号的 url。

首页

这正是脚本所遵循的步骤。

0030278592这是第 6 步中需要在输入框中输入的linc 编号。

我尝试过(工作之一,因为我在 中使用了硬编码的标题编号table_link):

import requests

from bs4 import BeautifulSoup


link = 'https://alta.registries.gov.ab.ca/spinii/logon.aspx'

lnotice = 'https://alta.registries.gov.ab.ca/spinii/legalnotice.aspx'

search_page = 'https://alta.registries.gov.ab.ca/SpinII/SearchSelectType.aspx'

map_page = 'http://alta.registries.gov.ab.ca/SpinII/mapindex.aspx'

map_find = 'http://alta.registries.gov.ab.ca/SpinII/mapfinds.aspx'

table_link = 'https://alta.registries.gov.ab.ca/SpinII/popupTitleSearch.aspx?title=628086906'


def get_content(s,link):   

    r = s.get(link)

    soup = BeautifulSoup(r.text,"lxml")

    payload = {i['name']:i.get('value','') for i in soup.select('input[name]')}

    payload['uctrlLogon:cmdLogonGuest.x'] = '80'

    payload['uctrlLogon:cmdLogonGuest.y'] = '20'


    r = s.post(link,data=payload)

    soup = BeautifulSoup(r.text,"lxml")

    payload = {i['name']:i.get('value','') for i in soup.select('input[name]')}

    payload['cmdYES.x'] = '52'

    payload['cmdYES.y'] = '8'


    s.post(lnotice,data=payload)

    s.headers['Referer'] = 'https://alta.registries.gov.ab.ca/spinii/welcomeguest.aspx'

    

    s.get(search_page)

    s.headers['Referer'] = 'https://alta.registries.gov.ab.ca/SpinII/SearchSelectType.aspx'

    

如何从 url 中获取标题编号?


或者


如何从该站点获取所有 linc 号码,以便我根本不需要使用地图?


The only problem with this site is that it is unavailable in daytime for maintenance.


天涯尽头无女友
浏览 125回答 2
2回答

拉风的咖菲猫

数据调用自:POST&nbsp;http://alta.registries.gov.ab.ca/SpinII/mapserver.aspx内容在被OpenLayers 库使用之前以自定义格式进行编码。所有的解码都位于这个JS文件中。如果你美化了,你可以找一下它的WayTo.Wtb.Format.WTB解码OpenLayers.Class。二进制文件按照 JS 中的如下所示逐字节解码:switch(elementType){&nbsp; &nbsp; case 1:&nbsp; &nbsp; &nbsp; &nbsp; var lineColor = new WayTo.Wtb.Element.LineColor();&nbsp; &nbsp; &nbsp; &nbsp; byteOffset = lineColor.parse(dataReader, byteOffset);&nbsp; &nbsp; &nbsp; &nbsp; outputElement = lineColor;&nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; &nbsp; case 2:&nbsp; &nbsp; &nbsp; &nbsp; var lineStyle = new WayTo.Wtb.Element.LineStyle();&nbsp; &nbsp; &nbsp; &nbsp; byteOffset = lineStyle.parse(dataReader, byteOffset);&nbsp; &nbsp; &nbsp; &nbsp; outputElement = lineStyle;&nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; &nbsp; case 3:&nbsp; &nbsp; &nbsp; &nbsp; var ellipse = new WayTo.Wtb.Element.Ellipse();&nbsp; &nbsp; &nbsp; &nbsp; byteOffset = ellipse.parse(dataReader, byteOffset);&nbsp; &nbsp; &nbsp; &nbsp; outputElement = ellipse;&nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp; &nbsp; ........}我们必须重现这个解码算法才能获得原始数据。我们不需要解码所有对象,我们只想获得正确的偏移量并strings正确提取。这里有一个Python解码部分的脚本,用于解码文件中的数据(输出卷曲):with open("wtb.bin", mode='rb') as file:&nbsp; &nbsp; encodedData = file.read()&nbsp; &nbsp; offset = 0&nbsp; &nbsp; objects = []&nbsp; &nbsp; while offset < len(encodedData):&nbsp; &nbsp; &nbsp; &nbsp; elementSize = encodedData[offset]&nbsp; &nbsp; &nbsp; &nbsp; offset+=1&nbsp; &nbsp; &nbsp; &nbsp; elementType = encodedData[offset]&nbsp; &nbsp; &nbsp; &nbsp; offset+=1&nbsp; &nbsp; &nbsp; &nbsp; if elementType == 0:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break&nbsp; &nbsp; &nbsp; &nbsp; curElemSize = elementSize&nbsp; &nbsp; &nbsp; &nbsp; curElemType = elementType&nbsp; &nbsp; &nbsp; &nbsp; if elementType== 114:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; largeElementSize = int.from_bytes(encodedData[offset:offset + 4], "big")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; largeElementType = int.from_bytes(encodedData[offset:offset+2], "little")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; curElemSize = largeElementSize&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; curElemType = largeElementType&nbsp; &nbsp; &nbsp; &nbsp; print(f"type {curElemType} | size {curElemSize}")&nbsp; &nbsp; &nbsp; &nbsp; offsetInit = offset&nbsp; &nbsp; &nbsp; &nbsp; if curElemType == 1:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 2:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 3:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=20&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 4:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=28&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 5:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=12&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 6:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textLength = curElemSize - 3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objects.append({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type": "Text",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "x_position": int.from_bytes(encodedData[offset:offset+2], "little"),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "y_position": int.from_bytes(encodedData[offset+2:offset+4], "little"),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "rotation": int.from_bytes(encodedData[offset+4:offset+6], "little"),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "text": encodedData[offset+6:offset+6+(textLength*2)].decode("utf-8").replace('\x00','')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=6+(textLength*2)&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 7:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numPoint = int(curElemSize / 2)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4*numPoint&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 27:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numPoint = int(curElemSize / 4)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=8*numPoint&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 8:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numPoint = int(curElemSize / 2)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4*numPoint&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 28:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numPoint = int(curElemSize / 4)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=8*numPoint&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 13:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 14:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 15:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 100:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 101:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=20&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 102:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 103:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 104:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highShort = int.from_bytes(encodedData[offset+2:offset+4], "little")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowShort = int.from_bytes(encodedData[offset+4:offset+6], "little")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objects.append({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type": "StartNumericCell",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "entity": int.from_bytes(encodedData[offset:offset+2], "little"),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "occurrence": (highShort << 16) + lowShort&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=6&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 105:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #end cell&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 109:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textLength = curElemSize - 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objects.append({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type": "StartAlphanumericCell",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "entity": int.from_bytes(encodedData[offset:offset+2], "little"),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "occurrence":encodedData[offset+2:offset+2+(textLength*2)].decode("utf-8").replace('\x00','')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2+(textLength*2)&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 111:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=40&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 112:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objects.append({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type": "CoordinatePlane",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "projection_code": encodedData[offset+48:offset+52].decode("utf-8").replace('\x00','')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=52&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 113:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=24&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 256:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nameLength = int.from_bytes(encodedData[offset+14:offset+16], "little")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objects.append({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type": "LargePolygon",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "name": encodedData[offset+16:offset+16+nameLength].decode("utf-8").replace('\x00',''),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "occurence": int.from_bytes(encodedData[offset+2:offset+6], "little")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if nameLength > 0:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+= 16 + nameLength&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if encodedData[offset] == 0:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+= 16&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numberOfPoints = int.from_bytes(encodedData[offset:offset+2], "little")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=numberOfPoints*8&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 257:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass&nbsp; &nbsp; &nbsp; &nbsp; else:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+= curElemSize*2&nbsp; &nbsp; &nbsp; &nbsp; print(f"offset diff {offset-offsetInit}")&nbsp; &nbsp; &nbsp; &nbsp; print("--------------------------------")&nbsp; &nbsp; print(objects)&nbsp; &nbsp; print(len(encodedData))&nbsp; &nbsp; print(offset)(旁注:请注意,元素大小采用大端字节序,所有其他值均采用小端字节序)运行这个 repl.it以查看它如何解码文件从那里我们构建了抓取数据的步骤,为了清楚起见,我将描述所有步骤(甚至是您已经弄清楚的步骤):登录使用以下命令登录网站:GET&nbsp;https://alta.registries.gov.ab.ca/spinii/logon.aspx抓取输入名称/值并添加uctrlLogon:cmdLogonGuest.x,uctrlLogon:cmdLogonGuest.y然后调用POST&nbsp;https://alta.registries.gov.ab.ca/spinii/logon.aspx法律声明法律声明调用对于获取地图值不是必需的,但对于获取项目信息是必需的(帖子中的最后一步)GET&nbsp;https://alta.registries.gov.ab.ca/spinii/legalnotice.aspx抓取input标签名称/值并设置cmdYES.x然后cmdYES.y调用POST&nbsp;https://alta.registries.gov.ab.ca/spinii/legalnotice.aspx地图数据调用服务器地图API:POST&nbsp;http://alta.registries.gov.ab.ca/SpinII/mapserver.aspx有以下数据:{&nbsp; &nbsp; "mt":"titleresults",&nbsp; &nbsp; "qt":"lincNo",&nbsp; &nbsp; "LINCNumber": lincNumber,&nbsp; &nbsp; "rights": "B", #not required&nbsp; &nbsp; "cx": 1920, #screen definition&nbsp; &nbsp; "cy": 1080,}cx/xy是画布尺寸使用上述方法对编码数据进行解码。你会得到 :[{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0010495134&nbsp;8722524;1;162',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628079167,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0012170859&nbsp;8022146;8;99',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628048595,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0010691822&nbsp;8722524;1;163',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628222354,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0012169736&nbsp;8022146;8;89',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628021327,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0010694454&nbsp;8722524;1;179',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628191678,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0010694362&nbsp;8722524;1;178',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628307403,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0010433381&nbsp;8722524;1;177',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628209696,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0012169710&nbsp;8022146;8;88A',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628021328,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0010694355&nbsp;8722524;1;176',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628315826,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0012170866&nbsp;8022146;8;100',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628163431,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,&nbsp;'line_color_blue':&nbsp;129,&nbsp;'fill_color_green':&nbsp;255,&nbsp;'fill_color_red':&nbsp;255,&nbsp;'fill_color_blue':&nbsp;180},&nbsp;{'type':&nbsp;'LargePolygon',&nbsp;'name':&nbsp;'0010694347&nbsp;8722524;1;175',&nbsp;'entity':&nbsp;23,&nbsp;'occurence':&nbsp;628132810,&nbsp;'line_color_green':&nbsp;0,&nbsp;'line_color_red':&nbsp;129,提取信息如果您想针对特定的目标,lincNumber则需要查找多边形的样式,因为对于“多个”值(例如具有多个项目的值),没有提及lincNumber响应的 id,只有链接引用。以下将获取所选项目:selectedZone = [&nbsp; &nbsp; t&nbsp;&nbsp; &nbsp; for t in objects&nbsp;&nbsp; &nbsp; if t.get("fill_color_green", 255) < 255 and t.get("line_color_red") == 255][0]print(selectedZone)调用您在帖子中提到的网址来获取数据并提取表:GET https://alta.registries.gov.ab.ca/SpinII/popupTitleSearch.aspx?title={selectedZone["occurence"]}完整代码:import requestsfrom bs4 import BeautifulSoupimport pandas as pdlincNumber = "0030278592"#lincNumber = "0010661156"s = requests.Session()# 1) loginr = s.get("https://alta.registries.gov.ab.ca/spinii/logon.aspx")soup = BeautifulSoup(r.text, "html.parser")payload = dict([&nbsp; &nbsp; (t["name"], t.get("value", ""))&nbsp; &nbsp; for t in soup.findAll("input")])payload["uctrlLogon:cmdLogonGuest.x"] = 76payload["uctrlLogon:cmdLogonGuest.y"] = 25s.post("https://alta.registries.gov.ab.ca/spinii/logon.aspx",data=payload)# 2) legal noticer = s.get("https://alta.registries.gov.ab.ca/spinii/legalnotice.aspx")soup = BeautifulSoup(r.text, "html.parser")payload = dict([&nbsp; &nbsp; (t["name"], t.get("value", ""))&nbsp; &nbsp; for t in soup.findAll("input")])payload["cmdYES.x"] = 82payload["cmdYES.y"] = 3s.post("https://alta.registries.gov.ab.ca/spinii/legalnotice.aspx", data = payload)# 3) map datar = s.post("http://alta.registries.gov.ab.ca/SpinII/mapserver.aspx",&nbsp; &nbsp; data= {&nbsp; &nbsp; &nbsp; &nbsp; "mt":"titleresults",&nbsp; &nbsp; &nbsp; &nbsp; "qt":"lincNo",&nbsp; &nbsp; &nbsp; &nbsp; "LINCNumber": lincNumber,&nbsp; &nbsp; &nbsp; &nbsp; "rights": "B", #not required&nbsp; &nbsp; &nbsp; &nbsp; "cx": 1920, #screen definition&nbsp; &nbsp; &nbsp; &nbsp; "cy": 1080,&nbsp; &nbsp; })def decodeWtb(encodedData):&nbsp; &nbsp; offset = 0&nbsp; &nbsp; objects = []&nbsp; &nbsp; iteration = 0&nbsp; &nbsp; while offset < len(encodedData):&nbsp; &nbsp; &nbsp; &nbsp; elementSize = encodedData[offset]&nbsp; &nbsp; &nbsp; &nbsp; offset+=1&nbsp; &nbsp; &nbsp; &nbsp; elementType = encodedData[offset]&nbsp; &nbsp; &nbsp; &nbsp; offset+=1&nbsp; &nbsp; &nbsp; &nbsp; if elementType == 0:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break&nbsp; &nbsp; &nbsp; &nbsp; curElemSize = elementSize&nbsp; &nbsp; &nbsp; &nbsp; curElemType = elementType&nbsp; &nbsp; &nbsp; &nbsp; if elementType== 114:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; largeElementSize = int.from_bytes(encodedData[offset:offset + 4], "big")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; largeElementType = int.from_bytes(encodedData[offset:offset+2], "little")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; curElemSize = largeElementSize&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; curElemType = largeElementType&nbsp; &nbsp; &nbsp; &nbsp; offsetInit = offset&nbsp; &nbsp; &nbsp; &nbsp; if curElemType == 1:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 2:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 3:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=20&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 4:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=28&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 5:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=12&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 6:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textLength = curElemSize - 3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=6+(textLength*2)&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 7:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numPoint = int(curElemSize / 2)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4*numPoint&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 27:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numPoint = int(curElemSize / 4)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=8*numPoint&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 8:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numPoint = int(curElemSize / 2)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4*numPoint&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 28:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numPoint = int(curElemSize / 4)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=8*numPoint&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 13:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=4&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 14:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 15:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 100:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 101:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=20&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 102:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 103:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 104:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=6&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 105:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 109:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textLength = curElemSize - 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2+(textLength*2)&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 111:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=40&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 112:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=52&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 113:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=24&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 256:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nameLength = int.from_bytes(encodedData[offset+14:offset+16], "little")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objects.append({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type": "LargePolygon",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "name": encodedData[offset+16:offset+16+nameLength].decode("utf-8").replace('\x00',''),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "entity": int.from_bytes(encodedData[offset:offset+2], "little"),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "occurence": int.from_bytes(encodedData[offset+2:offset+6], "little"),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "line_color_green": encodedData[offset + 8],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "line_color_red": encodedData[offset + 7],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "line_color_blue": encodedData[offset + 9],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "fill_color_green": encodedData[offset + 10],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "fill_color_red": encodedData[offset + 11],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "fill_color_blue": encodedData[offset + 13]&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if nameLength > 0:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+= 16 + nameLength&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if encodedData[offset] == 0:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+= 16&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numberOfPoints = int.from_bytes(encodedData[offset:offset+2], "little")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+=numberOfPoints*8&nbsp; &nbsp; &nbsp; &nbsp; elif curElemType == 257:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass&nbsp; &nbsp; &nbsp; &nbsp; else:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset+= curElemSize*2&nbsp; &nbsp; return objects# 4) decode custom formatobjects = decodeWtb(r.content)# 5) get the selected areaselectedZone = [&nbsp; &nbsp; t&nbsp;&nbsp; &nbsp; for t in objects&nbsp;&nbsp; &nbsp; if t.get("fill_color_green", 255) < 255 and t.get("line_color_red") == 255][0]print(selectedZone)# 6) get the info about itemr = s.get(f'https://alta.registries.gov.ab.ca/SpinII/popupTitleSearch.aspx?title={selectedZone["occurence"]}')df = pd.read_html(r.content, attrs = {'class': 'bodyText'}, header =0)[0]del df['Add to Cart']del df['View']print(df[:-1])在 repl.it 上运行这个输出&nbsp; Title Number&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Type LINC Number Short Legal&nbsp; &nbsp;Rights Registration Date Change/Cancel Date0&nbsp; &nbsp; 052400228&nbsp; Current Title&nbsp; 0030278592&nbsp; 0420091;16&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 19/09/2005&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;13/11/20191&nbsp; &nbsp; 072294084&nbsp; Current Title&nbsp; 0030278551&nbsp; 0420091;12&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 22/05/2007&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;21/08/20072&nbsp; &nbsp; 072400529&nbsp; Current Title&nbsp; 0030278469&nbsp; &nbsp;0420091;3&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 05/07/2007&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;28/08/20073&nbsp; &nbsp; 072498228&nbsp; Current Title&nbsp; 0030278501&nbsp; &nbsp;0420091;7&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 18/08/2007&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;08/02/20084&nbsp; &nbsp; 072508699&nbsp; Current Title&nbsp; 0030278535&nbsp; 0420091;10&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 23/08/2007&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;13/12/20075&nbsp; &nbsp; 072559500&nbsp; Current Title&nbsp; 0030278477&nbsp; &nbsp;0420091;4&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 17/09/2007&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;19/11/20076&nbsp; &nbsp; 072559508&nbsp; Current Title&nbsp; 0030278576&nbsp; 0420091;14&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 17/09/2007&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;09/01/20097&nbsp; &nbsp; 072559521&nbsp; Current Title&nbsp; 0030278519&nbsp; &nbsp;0420091;8&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 17/09/2007&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;07/11/20078&nbsp; &nbsp; 072559530&nbsp; Current Title&nbsp; 0030278493&nbsp; &nbsp;0420091;6&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 17/09/2007&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;25/08/20089&nbsp; &nbsp; 072559605&nbsp; Current Title&nbsp; 0030278485&nbsp; &nbsp;0420091;5&nbsp; Surface&nbsp; &nbsp; &nbsp; &nbsp; 17/09/2007&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;23/12/2008objects如果您想获得更多条目,可以查看该字段。如果您想获得有关坐标等项目的更多信息,您可以改进解码器......还可以通过查看包含 lincNumber 的字段来匹配目标周围的其他 lincNumber,name除非其中存在“多个”名称。

白猪掌柜的

有两种选择可以获取您正在寻找的信息,其中一种是您可能已经知道的硒。当您将鼠标悬停在地图上时,打开网络选项卡并监视浏览器传递的请求是否向服务器发出请求。对于请求和 BS4,您最好的选择是如果数据已经加载,那么下面的解决方案可能会起作用import&nbsp;re&nbsp; print(re.findall(r’628086906’,&nbsp;r.text)&nbsp;)如果它打印出数字,则意味着数据在 json 中可用并随页面一起加载,您可以加载 json 或使用正则表达式查找。否则你唯一的选择是硒
打开App,查看更多内容
随时随地看视频慕课网APP