这几天在学习selenium,顺便用selenium + python写了一个比较简陋的爬虫,现附上源码,有时间再补充补充:
1 from selenium import webdriver 2 from selenium.webdriver.support.wait import WebDriverWait 3 from selenium.webdriver.support import expected_conditions as EC 4 from selenium.webdriver.common.by import By 5 import os 6 7 class DouBan_Movies: 8 9 def __init__(self): 10 #初始化chromedriver 11 self.driver = webdriver.Chrome() 12 #调用函数进入豆瓣电影top250官网 13 self.__enter_douban() 14 #在当前目录下建一个文本文件用来写入电影信息 15 self.fs = open(os.getcwd() + r