import json import requests url=‘https://www.ptpress.com.cn/recommendBook/getRecommendBookListForPortal?bookTagId=2725fe7b-b2c2-4769-8f6f-c95f04c70275’ return_data = requests.get(url).text data = json.loads(return_data) news = data[‘data’] for n in news: bookName=n[‘bookName’] bookId=n[‘bookId’] print(‘新书名:’,bookName,’\n’,‘图书id:’,bookId) print(’\n’)
from selenium import webdriver driver = webdriver.Chrome(executable_path=r’D:\chromedriver.exe’) driver.get(‘https://careers.tencent.com/’) data = driver.page_source print(data) driver.quit()
from selenium import webdriver import time driver = webdriver.Chrome(executable_path=r’D:\chromedriver.exe’) driver.get(‘https://www.baidu.com/’) time.sleep(5) driver.save_screenshot(‘baidu.png’) data = driver.page_source print(data) driver.quit()
from selenium import webdriver from selenium.webdriver.common.by import By import time driver = webdriver.Chrome(executable_path=r’D:\chromedriver.exe’) driver.get(‘https://www.baidu.com/’) time.sleep(5) data = driver.find_element_by_id(‘s-top-left’) print(data) print(data.text) print(’=’*100) print(driver.title)
driver.save_screenshot(‘baidu.png’) driver.quit()
from selenium import webdriver from selenium.webdriver.common.by import By import time driver = webdriver.Chrome(executable_path=r’D:\chromedriver.exe’) driver.get(‘https://www.baidu.com/’) driver.find_element_by_class_name(‘s_ipt’).send_keys(u’长城’) driver.find_element_by_id(‘su’).click() #click()模拟点击
time.sleep(5) driver.save_screenshot(‘长城.png’) print(driver.get_cookies()) driver.quit()
from selenium import webdriver from selenium.webdriver.common.by import By driver = webdriver.Chrome(executable_path=r’D:\chromedriver.exe’) driver.get(‘https://www.ptpress.com.cn/’) list=driver.find_elements_by_css_selector(".box p") print(len(list)) for ab in list: tx=ab.text print(tx) driver.quit()