ADD file via upload

master
psofiq5z8 2 years ago
parent 457e7ba3aa
commit 713a3cc658

@ -0,0 +1,40 @@
import copy
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome("./venv/chromedriver.exe")#本地浏览器驱动地址,自行跟换
driver.implicitly_wait(60)
def get_book():
# http://www.ibiqu.org/modules/article/search.php?searchkey=
# #搜索书籍
Preurl = "http://www.ibiqu.org/modules/article/search.php?searchkey="
book_name = input("请输入书名:")
url = Preurl + book_name
driver.get(url)
#定位所有标签
bookinfor = driver.find_elements(by=By.CSS_SELECTOR, value=".grid .odd")
#存储书籍信息nameurlwriterlasttime
books = []
book = {}
for i in range(len(bookinfor)):
if (i + 1) % 3 == 1:
book["name"] = bookinfor[i].text
book["url"] = bookinfor[i].find_element(By.TAG_NAME,"a").get_attribute("href")
if (i + 1) % 3 == 2:
book["writer"] = bookinfor[i].text
if (i + 1) % 3 == 0:
book["lasttime"] = bookinfor[i].text
booki = copy.deepcopy(book)
books.append(booki)
print(books)
if __name__ == "__main__":
get_book()
while True:
pass
Loading…
Cancel
Save