Skip to content

Commit 460618f

Browse files
authored
Merge pull request #131 from jtwmyddsgx/patch-2
Update 3_Trip_Advisor.py
2 parents 9337c9a + 7f56954 commit 460618f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

week1/1_3/1_3code_of_video/3_Trip_Advisor.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def get_attractions(url,data=None):
1919
titles = soup.select('div.property_title > a[target="_blank"]')
2020
imgs = soup.select('img[width="160"]')
2121
cates = soup.select('div.p13n_reasoning_v2')
22-
2322
if data == None:
2423
for title,img,cate in zip(titles,imgs,cates):
2524
data = {
@@ -32,17 +31,18 @@ def get_attractions(url,data=None):
3231

3332
def get_favs(url,data=None):
3433
wb_data = requests.get(url,headers=headers)
34+
print(wb_data)
3535
soup = BeautifulSoup(wb_data.text,'lxml')
36-
titles = soup.select('a.location-name')
37-
imgs = soup.select('div.photo > div.sizedThumb > img.photo_image')
38-
metas = soup.select('span.format_address')
39-
36+
titles = soup.select("div.title.titleLLR > div")
37+
imgs = soup.find_all("div", "missing lazyMiss")
38+
metas = soup.select('div.attraction_types > span')
39+
4040
if data == None:
4141
for title,img,meta in zip(titles,imgs,metas):
4242
data = {
43-
'title' :title.get_text(),
44-
'img' :img.get('src'),
45-
'meta' :list(meta.stripped_strings)
43+
'title' :title.get_text().strip(),
44+
'img' :img.get('data-thumburl'),
45+
'meta' :meta.get_text()
4646
}
4747
print(data)
4848

0 commit comments

Comments
 (0)