爬取csdn的个人博客

爬取csdn的个人博客全文构思:本文使用账号密码进行登录,所用到的环境安装sudo pip3 install seleniumsudo pip3 install pyperclip除此之外使用了chrome的浏览器,需要下载驱动,自行百度使用selenium登录了之后,进行全选和复制(进入的是博客管理的界面)代码中的账号密码login_mobile.send_keys(‘xxx’)...
摘要由CSDN通过智能技术生成

爬取csdn的个人博客

全文构思:
本文使用账号密码进行登录,所用到的环境安装
sudo pip3 install selenium
sudo pip3 install pyperclip
除此之外使用了chrome的浏览器,需要下载驱动,自行百度

使用selenium登录了之后,进行全选和复制(进入的是博客管理的界面)

代码中的账号密码
login_mobile.send_keys(‘xxx’)
login_password.send_keys(‘xxx’)

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
import time,os
import pyperclip

class MyCrawl()
    def __init__(self):
        chrome_options = webdriver.ChromeOptions()
        # chrome_options.add_argument('--headless')
        self.browser = webdriver.Chrome(chrome_options=chrome_options)
        self.wait = WebDriverWait(self.browser, 2)
        self.browser.maximize_window()

    def get_one_page(self, my_url):
        self.browser.get(my_url)
        self.parse_page()

    def parse_page(self):
        titles = self.browser.find_elements_by_css_selector('.article-list-item-txt a')
        for title in titles:
            my_title = title.text
            print("文本标题", my_title)
            title.click()
            time.sleep(1
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值