Skip to content

Instantly share code, notes, and snippets.

@dapseen
Last active August 22, 2021 21:55
Show Gist options
  • Save dapseen/6ca6f5d252af448267b8a7f443fb6d3c to your computer and use it in GitHub Desktop.
Save dapseen/6ca6f5d252af448267b8a7f443fb6d3c to your computer and use it in GitHub Desktop.
Instascraper
from instascrape import *
#import instascrape
headers = {
"user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36 Edg/87.0.664.57",
"cookie":"sessionid=1573657342%3ACjfOyxQ2XdWAOx%3A0"
}
hashtag = Hashtag("https://www.instagram.com/explore/tags/abujarestaurant")
hashtag.scrape(headers=headers)
recent_post = hashtag.get_recent_posts(71)
for post in recent_post:
url = post.shortcode
from instascrape import *
from bs4 import BeautifulSoup
import requests
headers = {
"user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36 Edg/87.0.664.57",
"cookie":"sessionid=1573657342%3AIscEn69vCI05Bp%3A3"
}
hashtag = Hashtag("https://www.instagram.com/explore/tags/abujarestaurant")
hashtag.scrape(headers=headers)
recent_post = hashtag.get_recent_posts(71)
for post in recent_post:
url = post.shortcode
fmt_url = "https://instagram.com/p/"+url
caption = post.caption
username = post.username
print(caption,username,caption)
# req = requests.get(url, headers)
# soup = BeautifulSoup(req.content, 'html.parser')
# print(soup.prettify())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment