selenium爬取拉勾网数据并进行可视化分析

本文使用Selenium库爬取拉勾网职位信息,包括职位名称、薪资、公司等,然后对数据进行预处理,利用matplotlib和seaborn进行可视化分析,揭示互联网行业薪资分布、热门职位等趋势。
摘要由CSDN通过智能技术生成
"""
Created by Young on 2019/1/23 10:25
"""
import pymongo
from selenium import webdriver
from lxml import etree
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
import re

driver = webdriver.Chrome()
wait = WebDriverWait(driver,10)
url = 'https://www.lagou.com/jobs/list_python%E7%88%AC%E8%99%AB?oquery=python%E5%90%8E%E7%AB%AF&fromSearch=true&labelWords=relative'


client = pymongo.MongoClient('localhost',27017)
lagou = client['lagou']
meishi_info = lagou['lagou_job']

def job_link(url):

    driver.get(url)
    while True:
        source = driver.page_source
        time.sleep(2)
        page_list(source)
        next_btn = wait.until(EC.element_to_b
爬取淄博旅游数据可以通过以下步骤实现: 1. 确定数据源:可以在淄博旅游官、淄博市政府官站上寻找相关数据。 2. 确定爬取方式:可以通过手动爬取、Python爬虫等方式进行爬取。其中,Python爬虫可以使用BeautifulSoup、Selenium等库。 3. 确定数据存储方式:可以选择将数据存储为Excel、CSV等格式,也可以选择存储到数据库中。其中,存储到数据库中可以使用MySQL、MongoDB等数据库。 4. 确定数据分析方式:可以使用Python进行数据分析,例如使用Pandas、Matplotlib、Seaborn等库进行可视化分析。 下面给出一个简单的示例,以爬取淄博市旅游景点的名称、地址、评分、评论数等数据为例: 1. 爬取数据 使用Python爬虫库Requests和BeautifulSoup爬取淄博市旅游景点的名称、地址、评分、评论数等数据。 ```python import requests from bs4 import BeautifulSoup # 获取数据 url = 'http://www.zbly.net/jd/' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') # 解析数据 data = [] for item in soup.find_all('div', {'class': 'cn'}): name = item.find('a').text.strip() address = item.find('p', {'class': 'address'}).text.strip() score = item.find('span', {'class': 'score'}).text.strip() comment = item.find('span', {'class': 'comment'}).text.strip() data.append({'name': name, 'address': address, 'score': score, 'comment': comment}) # 存储数据 import pandas as pd df = pd.DataFrame(data) df.to_csv('data.csv', index=False) ``` 2. 数据可视化分析 使用Python数据分析库Pandas、Matplotlib和Seaborn进行数据可视化分析。 ```python import pandas as pd import matplotlib.pyplot as plt import seaborn as sns # 读取数据 df = pd.read_csv('data.csv') # 统计评分分布 fig, ax = plt.subplots(figsize=(8, 6)) sns.histplot(df['score'], bins=10, ax=ax) ax.set_xlabel('Score') ax.set_ylabel('Count') ax.set_title('Score Distribution') # 统计评论数分布 fig, ax = plt.subplots(figsize=(8, 6)) sns.histplot(df['comment'], bins=10, ax=ax) ax.set_xlabel('Comment') ax.set_ylabel('Count') ax.set_title('Comment Distribution') # 统计评分和评论数的关系 fig, ax = plt.subplots(figsize=(8, 6)) sns.scatterplot(x='score', y='comment', data=df, ax=ax) ax.set_xlabel('Score') ax.set_ylabel('Comment') ax.set_title('Score and Comment Relationship') ``` 通过以上步骤可以实现对淄博市旅游景点的数据爬取可视化分析
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值