我尝试使用钴进行远程调试。 我像这样推出钴:
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
import re
urls = ['https://www.extraspace.com/Storage/Facilities/US/North_Carolina/Charlotte/1000000398/Facility.aspx'
, 'https://www.extraspace.com/Storage/Facilities/US/North_Carolina/Charlotte/1000000404/Facility.aspx']
filename = "extraspace.csv"
open(filename, 'w').close()
f = open(filename, "a")
num = 0
headers = "unit_size_0, unit_size_1, size_dim1, unit_type, online_price, reg_price, street_address, store_city, store_postalcode\n"
f.write(headers)
for my_url in urls:
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")
street_address = page_soup.find("span", {"itemprop": "streetAddress"}).text
store_city = page_soup.find("span", {"itemprop": "addressLocality"}).text
store_postalcode = page_soup.find("span", {"itemprop": "postalCode"}).text
containers = page_soup.findAll("div", {"itemprop": "makesOffer"})
for container in containers:
title_container = container.findAll("div", {"class": "size RamaGothicSemiBold"})
size_dim = container.findAll("div", {"itemprop": "description"})
unit_type = container.findAll("ul", {"itemprop": "description"})
online_price = container.findAll("div", {"itemprop": "price"})
reg_price = container.findAll("div", {"class": "rate strikeout"})
for item in zip(title_container, size_dim, unit_type, online_price, reg_price ):
i= re.match(r"([^A-Z]*)([A-Z]*)", item[0].text.replace('\n', '').strip("\""))
csv = i.group(1) + "," + i.group(2) + "," + item[1].text + "," + item[2].text + "," + item[3].text + "," + item[4].text + "," \
+ street_address + "," + store_city + "," + store_postalcode + "\n"
f.write(csv)
num += 1
f.close()
之后,我使用此网址http://ip_adress_device_cobalt>:9222
启动Chrome当我尝试在开发人员工具选项卡中导航时,控制台工作正常,但其他选项卡(如网络,源)始终为空。 所以我无法使用断点或监听网络。
还有其他配置吗?
非常感谢任何帮助