Exemple #1
0
        print("Tag  \t\t\t\t\t Count")

        for tag_name in tagNameArray:

            # create url for each hashtag using api endpoint specification
            url = "https://api.instagram.com/v1/tags/" + tag_name + "?client_id=6cd753ceba494a209edf8459f42f9a37"

            # read the response
            response = requests.get(url).json()

            # extract the count
            data = tag_name + "-" + str(response['data']['media_count'])

            print(data)
            file.write("\n" + data)

        file.close()

    except Exception as e:
        file.close()
        print(e)
    except KeyboardInterrupt as e:
        file.close()
        print(e)


if __name__ == '__main__':

    taggedArray = getMergedArray()          # get the top places from both absolute visit and trip advisor
    getInstagramTagsCount(taggedArray)
Exemple #2
0
                    2)  # sleep to not exceed the limit of requests per second

            else:
                break

        file.write("\n" + hashtag + "---" +
                   str(count))  # write the tag and count in file
        print("Total Count: " + str(count))

        print(
            "\n-----------------------------------------------------------------------------------------------------------\n"
        )

    except Exception as e:
        print("Total Count: " + str(count))
        print(e)
    except KeyboardInterrupt as e:
        print("Total Count: " + str(count))
        print(e)
        file.close()
    except KeyError as e:
        pass


if __name__ == '__main__':

    taggedArray = getMergedArray()

    for tag in taggedArray:
        getTwitterHashTagCount(tag)
    file.close()
                else:
                    break

                time.sleep(2)   # sleep to not exceed the limit of requests per second

            else:
                break

        file.write("\n" + hashtag + "---" + str(count))     # write the tag and count in file
        print("Total Count: " + str(count))

        print("\n-----------------------------------------------------------------------------------------------------------\n")

    except Exception as e:
        print("Total Count: " + str(count))
        print(e)
    except KeyboardInterrupt as e:
        print("Total Count: " + str(count))
        print(e)
        file.close()
    except KeyError as e:
        pass


if __name__ == '__main__':

    taggedArray = getMergedArray()

    for tag in taggedArray:
        getTwitterHashTagCount(tag)
    file.close()