Created
          May 7, 2015 19:11 
        
      - 
      
- 
        Save iKlotho/f4addb33602bbd28cfdd to your computer and use it in GitHub Desktop. 
    Youtube annotations Scraper
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import requests | |
| from bs4 import BeautifulSoup | |
| # set userid to youtube channel id | |
| # script will get all the annotations from user's videos | |
| url = 'https://www.youtube.com/user/USERID/videos/browse_ajax?action_continuation=1&continuation=4qmFsgI8EhhVQ0VrOTBTOGl1SHQwZVV6Yks4TmtwX2caIEVnWjJhV1JsYjNNZ0FEQUJPQUZnQVdvQWVnRXl1QUVB' | |
| r = requests.get(url) | |
| soup = BeautifulSoup(r.text) | |
| lists = [] | |
| bas = 'https://www.youtube.com' | |
| for link in soup.find_all('h3','yt-lockup-title'): | |
| lists.append(link.a.get('href')) | |
| get = 'https://www.youtube.com/annotations_invideo?features=1&legacy=1&video_id=' | |
| for list in lists: | |
| gets = get + list[9:] | |
| r = requests.get(gets).text | |
| soup = BeautifulSoup(r) | |
| try: | |
| for i in soup.find_all('text'): | |
| print i.text | |
| except: | |
| pass | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment