-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetUrl.py
More file actions
30 lines (22 loc) · 880 Bytes
/
Copy pathgetUrl.py
File metadata and controls
30 lines (22 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from selenium import webdriver
import os,time,re
from bs4 import BeautifulSoup
import requests,cs1
class SearchUrl(object):
def __init__(self,searchM):
self.searchM = searchM
def start(self):
# searchM = '命运石之门'
url = 'https://movie.douban.com/subject_search?search_text={}'.format(self.searchM)
wb_data = requests.get(url)
soup = BeautifulSoup(wb_data.text, 'lxml')
titles = soup.select('#wrapper .article .pl2 a')
data = [x['href'] for x in titles]
data2 = [re.sub('[ \r\n]', '', x.get_text()) for x in titles]
return data[0]
# driver = webdriver.Chrome()
# driver.get(url)
# driver.find_element_by_css_selector("#inp-query").click()
# driver.find_element_by_css_selector("#inp-query").send_keys('命运')
# time.sleep(5)
# driver.find_element_by_css_selector(".inp-btn").click()