Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hung up on microsoft azure? #2

Open
jimccann-rh opened this issue Jun 1, 2023 · 2 comments
Open

hung up on microsoft azure? #2

jimccann-rh opened this issue Jun 1, 2023 · 2 comments

Comments

@jimccann-rh
Copy link

[jimb0@fedora ~]$ python -c "exec("import tg_ip_lookup\ntg_ip_lookup.cloudlookup.loadCloudProviderData.main('MaxMind License Key')")"
Processing AWS ranges...
Processing GCP ranges...
Processing Azure ranges...
Traceback (most recent call last):
File "", line 1, in
File "", line 2, in
File "/home/jimb0/.local/lib/python3.11/site-packages/tg_ip_lookup/cloudlookup/loadCloudProviderData.py", line 89, in main
azure_public_info = load_networks(lookup_microsoft_download_url('https://www.microsoft.com/en-us/download/confirmation.aspx?id=56519'),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jimb0/.local/lib/python3.11/site-packages/tg_ip_lookup/cloudlookup/loadCloudProviderData.py", line 63, in lookup_microsoft_download_url
download_url = soup.find('a', {'data-bi-containername': 'download retry'})['href']
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
[jimb0@fedora ~]$

@jimccann-rh
Copy link
Author

FYI I did put in my license key but did not want to show it on this portal

@emrul
Copy link
Contributor

emrul commented Jun 1, 2023

Hi @jimccann-rh - I've noticed this too and I think its because Microsoft have added code to detect automated downloads. As far as I can tell, they are the only cloud provider that make it difficult to programmatically download their IP ranges.

In any event, for now I've been able to work around the issue by replacing this line with the following:

    headers = {
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'
    }
    page = requests.get(url, headers=headers)

However, I suppose I must come up with a more fool proof method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants