Code Monkey home page Code Monkey logo

instagram-python-scraper's Introduction

instagram-python-scraper

this repo is now merging with realsirjoe/instagram-scraper, get latest version at 👉 instagram-scraper 👈

A instagram scraper wrote in python.Get medias, account, videos, comments without authentication.Comment and like action also supported.
Similar to instagram-php-scraper. Enjoy it! ☺️
**Any star or contribution would be appreciated if it is helpful for you ~** 🙋‍♂️🌚

install

You can simply run this command:

pip install instagram-python-scraper

Or you can also download it directly and install the libs that recorded in require.txt first.
Run the command below:

pip install -r requirements.txt

usages

Some methods require authentication:

from instagram_scraper.instagram import InstagramScraper

instagram = InstagramScraper()

# authentication supported
instagram.with_credentials('your account', 'your password')
res = instagram.login()

followers = instagram.get_followers('206034174', 20, 20, True)
print(followers[0])

If you use authentication the program will cache the user session by default so that you don't need to gain session everytime.
But if you want to disable the user session cache, just assign True to login() method:

from instagram_scraper.instagram import InstagramScraper

instagram = InstagramScraper()

instagram.with_credentials('your account', 'your password')
res = instagram.login(True)

Besides, account verification is also supported by default. When a account verification is needed, you will receive a active code by email or something and you should then input the code in terminal to finish verification.

Many of the methods do not require authentication:

from instagram_scraper.instagram import InstagramScraper

instagram = InstagramScraper()

account = instagram.get_account('shaq')
account_id = account.get_id()
print(account._id)

Using proxy for requests:

from instagram_scraper.instagram import InstagramScraper

proxies = {
    'http': 'http://127.0.0.1:1087',
    'https': 'http://127.0.0.1:1087',
}

instagram = InstagramScraper()
instagram.set_proxies(proxies)

account = instagram.get_account('shaq')
account_id = account.get_id()
print(account._id)

more usages

See more usages

once again:
**Any star or contribution would be appreciated if it is helpful for you ~** 🙋‍♂️🌚

other

php library:https://github.com/postaddictme/instagram-php-scraper

instagram-python-scraper's People

Contributors

luengwaiban avatar zianglei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

instagram-python-scraper's Issues

get_account_by_id Method is not working

Hi Great scapper!

Just encountered one issue: When I test get_account_by_id () by trying the examplar in your documentation, i.e.

account_by_id = instagram.get_account_by_id('11859524403')

it gives me

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\***\PycharmProjects\ins_fb_taqgs\venv\lib\site-packages\instagram_scraper\instagram.py", line 281, in get_account_by_id
    username = self.get_username_by_id(id)
  File "C:\Users\***\PycharmProjects\ins_fb_taqgs\venv\lib\site-packages\instagram_scraper\instagram.py", line 297, in get_username_by_id
    error_msg = 'Response code is: ' + str(response.status_code) + '. Body: ' + response.content + ' Something went wrong. Please report issue.'

TypeError: can only concatenate str (not "bytes") to str

get_medias_by_location_id 有問題

我執行
from instagram_scraper.instagram import InstagramScraper

instagram = InstagramScraper()
top_medias_by_location_id = instagram.get_current_top_medias_by_location_id(1)
print(top_medias_by_location_id[0].dict)
print(top_medias_by_location_id[0].get_link())
print(len(top_medias_by_location_id))
報錯
runfile('C:/Users/Desktop/test/untitled0.py', wdir='C:/Users/abc20/Desktop/test')
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/Desktop/test/untitled0.py', wdir='C:/Users/abc20/Desktop/test')

File "C:\Users\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)

File "C:\Users\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Desktop/test/untitled0.py", line 6, in
top_medias_by_location_id = instagram.get_current_top_medias_by_location_id(1)

File "C:\Users\Anaconda3\lib\site-packages\instagram_scraper\instagram.py", line 760, in get_current_top_medias_by_location_id
json_body = json.loads(response.text)

File "C:\Users\Anaconda3\lib\json_init_.py", line 348, in loads
return _default_decoder.decode(s)

File "C:\Users\Anaconda3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())

File "C:\Users\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None

JSONDecodeError: Expecting value

其他的我用都沒報錯,蠻好用的

期待你修復

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.