Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. import sys
  2. import requests
  3. from bs4 import BeautifulSoup
  4.  
  5. print('===== start =====')
  6. res = requests.get('https://tw.video.yahoo.com/')
  7. print(res.text)
  8. print('===== end =====')
  9.  
  10. # save the result into 'soup'
  11. soup = BeautifulSoup(res.text, 'html.parser')
  12.  
  13. linkArray = []
  14. titleArray = []
  15. combineArray = []
  16.  
  17. pageLink = 'https://tw.video.yahoo.com/'
  18. for link in soup.find_all('a', class_="W(290px)"):
  19.     linkArray.append(pageLink+link.get('href'))
  20.     print(pageLink+link.get('href'))
  21.  
  22. for title in soup.find_all('h2', class_="Fz(16px)"):
  23.     titleArray.append(title.text)
  24.     print(title.text)
  25.  
  26. for i in range(len(linkArray)):
  27.     combineArray.append(titleArray[i]+' '+linkArray[i])
  28.     print(titleArray[i]+' '+linkArray[i])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement