python - How to scrape Instagram with BeautifulSoup -


i want scrape pictures public instagram account. i'm pretty familiar bs4 started that. using element inspector on chrome, noted pictures in unordered list , li has class 'photo', figure, hell -- can't hard scrape findall, right?

wrong: doesn't return (code below) , notice the code shown in element inspector , code drew requests not same aka no unordered list in code pulled requests.

any idea how can code shows in element inspector?

just record, code start, didn't work because unordered list not there:

from bs4 import beautifulsoup import requests import re  r = requests.get('http://instagram.com/umnpics/') soup = beautifulsoup(r.text) x in soup.findall('li', {'class':'photo'}):     print x 

thank help.

if @ source code page, you'll see javascript generates webpage. see in element browser webpage after script has been run, , beautifulsoup gets html file. in order parse rendered webpage you'll need use selenium render webpage you.

so, example, how selenium:

from bs4 import beautifulsoup import selenium.webdriver webdriver  url = 'http://instagram.com/umnpics/' driver = webdriver.firefox() driver.get(url)  soup = beautifulsoup(driver.page_source)  x in soup.findall('li', {'class':'photo'}):     print x 

now soup should expecting.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -