爬取聚合数据的全国房价排行榜
from selenium import webdriver
from bs4 import BeautifulSoup
import csv
from selenium import webdriver
from fake_useragent import UserAgent
import random
import subprocess
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import os
ips = []
with open('ip.txt', 'r') as f:
for line in f:
ip = line.strip()
ips.append(ip.strip())
# 启动Chrome浏览器调试服务
subprocess.Popen('cmd', shell=True)
subprocess.Popen('"chrome-win64\chrome.exe" --remote-debugging-port=9222', shell=True)
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("debuggerAddress", "localhost:9222")
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable‐gpu')
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument('--proxy-server=http://' + random.choice(ips))
chrome_options.add_argument(f"user-agent={
UserAgent().random}"

本文介绍了如何使用Python的Selenium和BeautifulSoup库从网站抓取全国房价排行榜数据,并将其存储到CSV文件中,最后使用matplotlib进行数据可视化,展示不同城市的二手房和新房价格趋势。
最低0.47元/天 解锁文章
1174

被折叠的 条评论
为什么被折叠?



