Advertisement
sasa2742002

Untitled

Sep 21st, 2023
1,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.90 KB | None | 0 0
  1. import re
  2. from pymongo import MongoClient
  3. import json
  4. from bs4 import BeautifulSoup
  5. import requests
  6.  
  7. all_regions = []
  8.  
  9. north_america = [
  10.     ["US East (N. Virginia)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/US%20East%20(N.%20Virginia)/Linux/index.json?timestamp=1695335197182"],
  11.     ["US East (N. California)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/US%20West%20(N.%20California)/Linux/index.json?timestamp=1695335943885"],
  12.     ["US West (Oregon)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/US%20West%20(Oregon)/Linux/index.json?timestamp=1695336005767"],
  13.     ["Canada (Central)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Canada%20(Central)/Linux/index.json?timestamp=1695336038545"],
  14.     ["AWS GovCloud (US-East)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/AWS%20GovCloud%20(US-East)/Linux/index.json?timestamp=1695336076977"],
  15.     ["AWS GovCloud (US-West)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/AWS%20GovCloud%20(US)/Linux/index.json?timestamp=1695336143250"]
  16. ]
  17.  
  18. africa = [
  19.     ["Africa (Cape Town)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Africa%20(Cape%20Town)/Linux/index.json?timestamp=1695336201165"]
  20. ]
  21.  
  22. asia_pacific = [
  23.     ["Asia Pacific (Hong Kong)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Asia%20Pacific%20(Hong%20Kong)/Linux/index.json?timestamp=1695336236566"],
  24.     ["Asia Pacific (Hyderabad)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Asia%20Pacific%20(Hyderabad)/Linux/index.json?timestamp=1695336267211"],
  25.     ["Asia Pacific (Jakarta)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Asia%20Pacific%20(Jakarta)/Linux/index.json?timestamp=1695336335452"],
  26.     ["Asia Pacific (Melbourne)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Asia%20Pacific%20(Melbourne)/Linux/index.json?timestamp=1695336377353"],
  27.     ["Asia Pacific (Mumbai)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Asia%20Pacific%20(Mumbai)/Linux/index.json?timestamp=1695336414559"],
  28.     ["Asia Pacific (Osaka)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Asia%20Pacific%20(Osaka)/Linux/index.json?timestamp=1695336448367"],
  29.     ["Asia Pacific (Seoul)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Asia%20Pacific%20(Seoul)/Linux/index.json?timestamp=1695336489384"],
  30.     ["Asia Pacific (Singapore)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Asia%20Pacific%20(Singapore)/Linux/index.json?timestamp=1695336516652"],
  31.     ["Asia Pacific (Sydney)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Australia%20(Sydney)/Linux/index.json?timestamp=1695336549342"],
  32.     ["Asia Pacific (Tokyo)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Australia%20(Tokyo)/Linux/index.json?timestamp=1695336572681"]
  33. ]
  34.  
  35. europe = [
  36.     ["Europe (Frankfurt)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/EU%20(Frankfurt)/Linux/index.json?timestamp=1695336606682"],
  37.     ["Europe (Ireland)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/EU%20(Ireland)/Linux/index.json?timestamp=1695336640824"],
  38.     ["Europe (London)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/EU%20(London)/Linux/index.json?timestamp=1695336671834"],
  39.     ["Europe (Milan)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/EU%20(Milan)/Linux/index.json?timestamp=1695336709113"],
  40.     ["Europe (Paris)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/EU%20(Paris)/Linux/index.json?timestamp=1695336734334"],
  41.     ["Europe (Spain)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/EU%20(Spain)/Linux/index.json?timestamp=1695336756525"],
  42.     ["Europe (Stockholm)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/EU%20(Stockholm)/Linux/index.json?timestamp=1695336795677"],
  43.     ["Europe (Zurich)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/EU%20(Zurich)/Linux/index.json?timestamp=1695336817871"]
  44. ]
  45.  
  46. middle_east = [
  47.     ["Middle East (Bahrain)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Middle%20East%20(Bahrain)/Linux/index.json?timestamp=1695336880976"],
  48.     ["Middle East (UAE)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/Middle%20East%20(UAE)/Linux/index.json?timestamp=1695336906621"]
  49. ]
  50.  
  51. south_america = [
  52.     ["South America (Sao Paulo)", "https://b0.p.awsstatic.com/pricing/2.0/meteredUnitMaps/ec2/USD/current/ec2-ondemand-without-sec-sel/South%20America%20(Sao%20Paulo)/Linux/index.json?timestamp=1695336944637"]
  53. ]
  54.  
  55. # Fetch data for each region
  56. for region_list in [north_america, africa, asia_pacific, europe, middle_east, south_america]:
  57.     for region in region_list:
  58.         data = requests.get(region[1]).json()
  59.         all_regions.append(data['regions'])
  60.  
  61. print(len(all_regions))
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement