Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import urllib.request
- import urllib.parse
- import urllib.error
- from bs4 import BeautifulSoup
- import ssl
- import json
- url = #instagram url
- driver = webdriver.Firefox()
- driver.get(url)
- for n in range(2):
- driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
- pageSource=driver.page_source
- soup = BeautifulSoup(pageSource, 'html.parser')
- body = soup.find('body')
- script = body.find('script')
- raw = script.text.strip().replace('window._sharedData =', '').replace(';', '')
- json_data=json.loads(raw)
- for post in json_data['entry_data']['ProfilePage'][0]['graphql']['user']['edge_owner_to_timeline_media']['edges']:
- text_src = post['node']['edge_media_to_caption']['edges'][0]['node']['text']
- print (text_src)
- time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement