使用selenium对卡车之家论坛进行爬虫

本文主要介绍如何利用selenium库对卡车之家论坛进行网页爬虫操作,通过实例代码展示具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

直接上代码
# -*- coding: utf-8 -*-
# @Time    : 2019/1/24 14:36
# @Author  : Merlin
# @Email   : shiehmerlin@gmail.com
# @File    : kachezhijialuntan.py
# @Software: PyCharm Community Edition

import selenium
from selenium import webdriver
import os,requests,time
import sys

from config import weizhi,urldef,Light_truck,Medium_truck,Heavy_truck,Dump_truck,truck,tag, pagenum,package_path,file_path

reload(sys)
sys.setdefaultencoding('utf8')

def start():
	options = webdriver.ChromeOptions()
	options.add_argument("--headless")  # 设置火狐为headless无界面模式
	options.add_argument("--disable-gpu")
	d = webdriver.Chrome(options=options)
	# #
	# d = webdriver.Chrome()
	return d
d = start()
def stop():
	d.quit()
#######################################################


# path = package_path[0] + file_path[0]
#######################################################

# count = 2
def query_write(path):

	commont = d.find_element_by_xpath(weizhi['heard'] + str(count) + weizhi['common'])
	start = d.find_element_by_xpath(weizhi['heard'] + str(count) + weizhi['startdate'])
	end = d.find_element_by_xpath(weizhi['heard'] + str(count) + weizhi['enddate'])
	huifu = d.find_element_by_xpath(weizhi['heard'
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值