需要从以下网站报废多页数据
https://dubai.dubizzle.com/en/property-for-rent/commercial/office/?page=1
要获取的字段是多个页面的"Price,description,area和location“。我只写了下面的代码。此外,我不知道如何解析电话号码,因为它只在你打开特定链接时出现
from urllib.request import urlopen
from bs4 import BeautifulSoup
file = "Dubizzle.csv"
f = open(file, "w")
Headers = "Price,Area,Description,Location,Website\n"
f.write(Headers)
for page in range(1, 4):
url = "https://dubai.dubizzle.com/en/property-for-rent/commercial/office/?page={}".format(page)
html = urlopen(url)
soup = BeautifulSoup(html, "html.parser")
发布于 2017-11-20 11:37:03
为了查看电话号码,你必须点击“显示电话号码”按钮,这是正确的。但在检查页面的元素后,您可以看到电话号码已经存在,它只是被隐藏起来,并将在您单击按钮后出现在页面上。
<img class="phone-num-img" src="data:image/png;base64,...
不幸的是,电话号码被保存为PNG图像,所以即使它在那里,您也必须以某种方式解析图像以获得电话号码本身。
https://stackoverflow.com/questions/47390100
复制相似问题