Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Get pagination Instagram
#1
Hello, I'm trying to automate my script(in Python) to automatically get the end_cursor in succession. For example:

https://www.instagram.com/explore/tags/plebiscito/?__a=1
after:

https://www.instagram.com/explore/tags/p...Y4AAAAFiYA

after:

https://www.instagram.com/explore/tags/p...jPAAAAFkwA

.... .... ....

And do so, until the end of the last end_cursor. I would appreciate it if you would help me, since I could not. Thank you very much again.

PD: I'm not doing it with the API, because of the problem that the Sandbox does not allow applications in development.

And this is a portion of my code:


 

def connect_main():
    tag="plebiscito"
    links_photos = []
    links2_photos = []
    links3_photos = [] # Save all links of ID.
    main_page_tag = ("https://www.instagram.com/explore/tags/%s/?__a=1" % tag)
    
    if(flag):
        url_get = requests.get(main_page_tag)
        load_json = json.loads(url_get.text)
        end_cursor = load_json['tag']['media']['page_info']['end_cursor']
        next_page = ("https://www.instagram.com/explore/tags/%s/?__a=1&%s" % (tag,end_cursor))
        count = 0
        while count < 40:
            try:
                #print(load_json['tag']['media']['nodes'][count]['code'])
                #print(load_json['tag']['top_posts']["nodes"][count]['code'])
                links_photos.append(load_json['tag']['media']['nodes'][count]['code'])
                links2_photos.append(load_json['tag']['top_posts']["nodes"][count]['code'])
                count = count + 1
            except:
                count = count + 1
           
        #for save in load_json['tag']['media']['nodes'][count]['code']:
           # print(save)
                    # Guardamos en la lista el ID de la foto, por ejemplo BMMbJkRAQfX, BMMbJkRAQfX, BMMZpRAg_Gn.
            #links_photos.append(save)
        for node1 in links_photos:
            links3_photos.append(node1)
        for node2 in links2_photos:
            links3_photos.append(node2)
        #for nodes in links3_photos:
        #    print(mirar)
        get_comments_data(links3_photos)
   
    else:
        #flag_id = True
        links_photos_next = []
        links2_photos_next2 = []
        links3_photos_nodes = [] # Save all links of ID.
        #url_get = requests.get(next_page)
        #if(flag_id)
        url_get = requests.get(next_page)
        iterate_max_ids(next_page)
        url_get = requests.get("https://www.instagram.com/explore/tags/%s/?__a=1&%s" % (tag,end_cursor_update)) 
        load_json2 = json.loads(url_get.text)
        count = 0
        while count < 40:
            try:
                #print(load_json['tag']['media']['nodes'][count]['code'])
                #print(load_json['tag']['top_posts']["nodes"][count]['code'])
                links_photos_next.append(load_json2['tag']['media']['nodes'][count]['code'])
                links2_photos_next2.append(load_json2['tag']['top_posts']["nodes"][count]['code'])
                count = count + 1
            except:
                count = count + 1
           
        #for save in load_json['tag']['media']['nodes'][count]['code']:
           # print(save)
                    # Guardamos en la lista el ID de la foto, por ejemplo BMMbJkRAQfX, BMMbJkRAQfX, BMMZpRAg_Gn.
            #links_photos.append(save)
        for node1 in links_photos_next:
            links3_photos.append(node1)
        for node2 in links2_photos_next2:
            links3_photos_nodes.append(node2)
        #for nodes in links3_photos:
        #    print(mirar)
        get_comments_data(links3_photos_nodes)


Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Instagram pagination tags Kalet 1 2,342 Dec-14-2016, 09:56 PM
Last Post: nilamo
  Python Instagram bot user-following problem danotto 1 2,386 Dec-11-2016, 10:36 PM
Last Post: Blue Dog
  I need help with an instagram bot bobduckling221 2 3,111 Oct-02-2016, 04:59 PM
Last Post: Ofnuts

Forum Jump:


Users browsing this thread: 1 Guest(s)