Skip to content

Commit 280df5f

Browse files
country scrapped
1 parent 696dce9 commit 280df5f

File tree

3 files changed

+307
-7
lines changed

3 files changed

+307
-7
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
import requests, os
3+
from bs4 import BeautifulSoup as bs
4+
import pandas as pd
5+
6+
try: os.mkdir('Scrapped')
7+
except: pass
8+
9+
link = 'https://www.scrapethissite.com/pages/simple/'
10+
req = requests.get(link)
11+
soup = bs(req.content, 'html5lib')
12+
13+
data = {}
14+
countryname = []
15+
countrycapital = []
16+
countrypopulation = []
17+
countryarea = []
18+
19+
country_name = soup.findAll('h3', attrs = {'class':'country-name'})
20+
for i in country_name:
21+
countryname.append(i.text.strip())
22+
23+
country_capital = soup.findAll('span', attrs = {'class':'country-capital'})
24+
for i in country_capital:
25+
countrycapital.append(i.text.strip())
26+
27+
country_population = soup.findAll('span', attrs = {'class':'country-population'})
28+
for i in country_population:
29+
countrypopulation.append(i.text.strip())
30+
31+
country_area = soup.findAll('span', attrs = {'class':'country-area'})
32+
for i in country_area:
33+
countryarea.append(i.text.strip())
34+
35+
data.update({"Country" : countryname})
36+
data.update({"Capital" : countrycapital})
37+
data.update({"Population" : countrypopulation})
38+
data.update({"Area (km2)" : countryarea})
39+
40+
df = pd.DataFrame.from_dict(
41+
data,
42+
orient='index'
43+
)
44+
45+
df.transpose().to_csv(
46+
'Scrapped/Countries of the World.csv',
47+
index = False,
48+
encoding='utf-8'
49+
)
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
Country,Capital,Population,Area (km2)
2+
Andorra,Andorra la Vella,84000,468.0
3+
United Arab Emirates,Abu Dhabi,4975593,82880.0
4+
Afghanistan,Kabul,29121286,647500.0
5+
Antigua and Barbuda,St. John's,86754,443.0
6+
Anguilla,The Valley,13254,102.0
7+
Albania,Tirana,2986952,28748.0
8+
Armenia,Yerevan,2968000,29800.0
9+
Angola,Luanda,13068161,1246700.0
10+
Antarctica,None,0,1.4E7
11+
Argentina,Buenos Aires,41343201,2766890.0
12+
American Samoa,Pago Pago,57881,199.0
13+
Austria,Vienna,8205000,83858.0
14+
Australia,Canberra,21515754,7686850.0
15+
Aruba,Oranjestad,71566,193.0
16+
Åland,Mariehamn,26711,1580.0
17+
Azerbaijan,Baku,8303512,86600.0
18+
Bosnia and Herzegovina,Sarajevo,4590000,51129.0
19+
Barbados,Bridgetown,285653,431.0
20+
Bangladesh,Dhaka,156118464,144000.0
21+
Belgium,Brussels,10403000,30510.0
22+
Burkina Faso,Ouagadougou,16241811,274200.0
23+
Bulgaria,Sofia,7148785,110910.0
24+
Bahrain,Manama,738004,665.0
25+
Burundi,Bujumbura,9863117,27830.0
26+
Benin,Porto-Novo,9056010,112620.0
27+
Saint Barthélemy,Gustavia,8450,21.0
28+
Bermuda,Hamilton,65365,53.0
29+
Brunei,Bandar Seri Begawan,395027,5770.0
30+
Bolivia,Sucre,9947418,1098580.0
31+
Bonaire,Kralendijk,18012,328.0
32+
Brazil,Brasília,201103330,8511965.0
33+
Bahamas,Nassau,301790,13940.0
34+
Bhutan,Thimphu,699847,47000.0
35+
Bouvet Island,None,0,49.0
36+
Botswana,Gaborone,2029307,600370.0
37+
Belarus,Minsk,9685000,207600.0
38+
Belize,Belmopan,314522,22966.0
39+
Canada,Ottawa,33679000,9984670.0
40+
Cocos [Keeling] Islands,West Island,628,14.0
41+
Democratic Republic of the Congo,Kinshasa,70916439,2345410.0
42+
Central African Republic,Bangui,4844927,622984.0
43+
Republic of the Congo,Brazzaville,3039126,342000.0
44+
Switzerland,Bern,7581000,41290.0
45+
Ivory Coast,Yamoussoukro,21058798,322460.0
46+
Cook Islands,Avarua,21388,240.0
47+
Chile,Santiago,16746491,756950.0
48+
Cameroon,Yaoundé,19294149,475440.0
49+
China,Beijing,1330044000,9596960.0
50+
Colombia,Bogotá,47790000,1138910.0
51+
Costa Rica,San José,4516220,51100.0
52+
Cuba,Havana,11423000,110860.0
53+
Cape Verde,Praia,508659,4033.0
54+
Curacao,Willemstad,141766,444.0
55+
Christmas Island,Flying Fish Cove,1500,135.0
56+
Cyprus,Nicosia,1102677,9250.0
57+
Czech Republic,Prague,10476000,78866.0
58+
Germany,Berlin,81802257,357021.0
59+
Djibouti,Djibouti,740528,23000.0
60+
Denmark,Copenhagen,5484000,43094.0
61+
Dominica,Roseau,72813,754.0
62+
Dominican Republic,Santo Domingo,9823821,48730.0
63+
Algeria,Algiers,34586184,2381740.0
64+
Ecuador,Quito,14790608,283560.0
65+
Estonia,Tallinn,1291170,45226.0
66+
Egypt,Cairo,80471869,1001450.0
67+
Western Sahara,Laâyoune / El Aaiún,273008,266000.0
68+
Eritrea,Asmara,5792984,121320.0
69+
Spain,Madrid,46505963,504782.0
70+
Ethiopia,Addis Ababa,88013491,1127127.0
71+
Finland,Helsinki,5244000,337030.0
72+
Fiji,Suva,875983,18270.0
73+
Falkland Islands,Stanley,2638,12173.0
74+
Micronesia,Palikir,107708,702.0
75+
Faroe Islands,Tórshavn,48228,1399.0
76+
France,Paris,64768389,547030.0
77+
Gabon,Libreville,1545255,267667.0
78+
United Kingdom,London,62348447,244820.0
79+
Grenada,St. George's,107818,344.0
80+
Georgia,Tbilisi,4630000,69700.0
81+
French Guiana,Cayenne,195506,91000.0
82+
Guernsey,St Peter Port,65228,78.0
83+
Ghana,Accra,24339838,239460.0
84+
Gibraltar,Gibraltar,27884,6.5
85+
Greenland,Nuuk,56375,2166086.0
86+
Gambia,Bathurst,1593256,11300.0
87+
Guinea,Conakry,10324025,245857.0
88+
Guadeloupe,Basse-Terre,443000,1780.0
89+
Equatorial Guinea,Malabo,1014999,28051.0
90+
Greece,Athens,11000000,131940.0
91+
South Georgia and the South Sandwich Islands,Grytviken,30,3903.0
92+
Guatemala,Guatemala City,13550440,108890.0
93+
Guam,Hagåtña,159358,549.0
94+
Guinea-Bissau,Bissau,1565126,36120.0
95+
Guyana,Georgetown,748486,214970.0
96+
Hong Kong,Hong Kong,6898686,1092.0
97+
Heard Island and McDonald Islands,None,0,412.0
98+
Honduras,Tegucigalpa,7989415,112090.0
99+
Croatia,Zagreb,4491000,56542.0
100+
Haiti,Port-au-Prince,9648924,27750.0
101+
Hungary,Budapest,9982000,93030.0
102+
Indonesia,Jakarta,242968342,1919440.0
103+
Ireland,Dublin,4622917,70280.0
104+
Israel,None,7353985,20770.0
105+
Isle of Man,Douglas,75049,572.0
106+
India,New Delhi,1173108018,3287590.0
107+
British Indian Ocean Territory,None,4000,60.0
108+
Iraq,Baghdad,29671605,437072.0
109+
Iran,Tehran,76923300,1648000.0
110+
Iceland,Reykjavik,308910,103000.0
111+
Italy,Rome,60340328,301230.0
112+
Jersey,Saint Helier,90812,116.0
113+
Jamaica,Kingston,2847232,10991.0
114+
Jordan,Amman,6407085,92300.0
115+
Japan,Tokyo,127288000,377835.0
116+
Kenya,Nairobi,40046566,582650.0
117+
Kyrgyzstan,Bishkek,5776500,198500.0
118+
Cambodia,Phnom Penh,14453680,181040.0
119+
Kiribati,Tarawa,92533,811.0
120+
Comoros,Moroni,773407,2170.0
121+
Saint Kitts and Nevis,Basseterre,51134,261.0
122+
North Korea,Pyongyang,22912177,120540.0
123+
South Korea,Seoul,48422644,98480.0
124+
Kuwait,Kuwait City,2789132,17820.0
125+
Cayman Islands,George Town,44270,262.0
126+
Kazakhstan,Astana,15340000,2717300.0
127+
Laos,Vientiane,6368162,236800.0
128+
Lebanon,Beirut,4125247,10400.0
129+
Saint Lucia,Castries,160922,616.0
130+
Liechtenstein,Vaduz,35000,160.0
131+
Sri Lanka,Colombo,21513990,65610.0
132+
Liberia,Monrovia,3685076,111370.0
133+
Lesotho,Maseru,1919552,30355.0
134+
Lithuania,Vilnius,2944459,65200.0
135+
Luxembourg,Luxembourg,497538,2586.0
136+
Latvia,Riga,2217969,64589.0
137+
Libya,Tripoli,6461454,1759540.0
138+
Morocco,Rabat,31627428,446550.0
139+
Monaco,Monaco,32965,1.95
140+
Moldova,Chişinău,4324000,33843.0
141+
Montenegro,Podgorica,666730,14026.0
142+
Saint Martin,Marigot,35925,53.0
143+
Madagascar,Antananarivo,21281844,587040.0
144+
Marshall Islands,Majuro,65859,181.3
145+
Macedonia,Skopje,2062294,25333.0
146+
Mali,Bamako,13796354,1240000.0
147+
Myanmar [Burma],Naypyitaw,53414374,678500.0
148+
Mongolia,Ulan Bator,3086918,1565000.0
149+
Macao,Macao,449198,254.0
150+
Northern Mariana Islands,Saipan,53883,477.0
151+
Martinique,Fort-de-France,432900,1100.0
152+
Mauritania,Nouakchott,3205060,1030700.0
153+
Montserrat,Plymouth,9341,102.0
154+
Malta,Valletta,403000,316.0
155+
Mauritius,Port Louis,1294104,2040.0
156+
Maldives,Malé,395650,300.0
157+
Malawi,Lilongwe,15447500,118480.0
158+
Mexico,Mexico City,112468855,1972550.0
159+
Malaysia,Kuala Lumpur,28274729,329750.0
160+
Mozambique,Maputo,22061451,801590.0
161+
Namibia,Windhoek,2128471,825418.0
162+
New Caledonia,Noumea,216494,19060.0
163+
Niger,Niamey,15878271,1267000.0
164+
Norfolk Island,Kingston,1828,34.6
165+
Nigeria,Abuja,154000000,923768.0
166+
Nicaragua,Managua,5995928,129494.0
167+
Netherlands,Amsterdam,16645000,41526.0
168+
Norway,Oslo,5009150,324220.0
169+
Nepal,Kathmandu,28951852,140800.0
170+
Nauru,Yaren,10065,21.0
171+
Niue,Alofi,2166,260.0
172+
New Zealand,Wellington,4252277,268680.0
173+
Oman,Muscat,2967717,212460.0
174+
Panama,Panama City,3410676,78200.0
175+
Peru,Lima,29907003,1285220.0
176+
French Polynesia,Papeete,270485,4167.0
177+
Papua New Guinea,Port Moresby,6064515,462840.0
178+
Philippines,Manila,99900177,300000.0
179+
Pakistan,Islamabad,184404791,803940.0
180+
Poland,Warsaw,38500000,312685.0
181+
Saint Pierre and Miquelon,Saint-Pierre,7012,242.0
182+
Pitcairn Islands,Adamstown,46,47.0
183+
Puerto Rico,San Juan,3916632,9104.0
184+
Palestine,None,3800000,5970.0
185+
Portugal,Lisbon,10676000,92391.0
186+
Palau,Melekeok,19907,458.0
187+
Paraguay,Asunción,6375830,406750.0
188+
Qatar,Doha,840926,11437.0
189+
Réunion,Saint-Denis,776948,2517.0
190+
Romania,Bucharest,21959278,237500.0
191+
Serbia,Belgrade,7344847,88361.0
192+
Russia,Moscow,140702000,1.71E7
193+
Rwanda,Kigali,11055976,26338.0
194+
Saudi Arabia,Riyadh,25731776,1960582.0
195+
Solomon Islands,Honiara,559198,28450.0
196+
Seychelles,Victoria,88340,455.0
197+
Sudan,Khartoum,35000000,1861484.0
198+
Sweden,Stockholm,9828655,449964.0
199+
Singapore,Singapore,4701069,692.7
200+
Saint Helena,Jamestown,7460,410.0
201+
Slovenia,Ljubljana,2007000,20273.0
202+
Svalbard and Jan Mayen,Longyearbyen,2550,62049.0
203+
Slovakia,Bratislava,5455000,48845.0
204+
Sierra Leone,Freetown,5245695,71740.0
205+
San Marino,San Marino,31477,61.2
206+
Senegal,Dakar,12323252,196190.0
207+
Somalia,Mogadishu,10112453,637657.0
208+
Suriname,Paramaribo,492829,163270.0
209+
South Sudan,Juba,8260490,644329.0
210+
São Tomé and Príncipe,São Tomé,175808,1001.0
211+
El Salvador,San Salvador,6052064,21040.0
212+
Sint Maarten,Philipsburg,37429,21.0
213+
Syria,Damascus,22198110,185180.0
214+
Swaziland,Mbabane,1354051,17363.0
215+
Turks and Caicos Islands,Cockburn Town,20556,430.0
216+
Chad,N'Djamena,10543464,1284000.0
217+
French Southern Territories,Port-aux-Français,140,7829.0
218+
Togo,Lomé,6587239,56785.0
219+
Thailand,Bangkok,67089500,514000.0
220+
Tajikistan,Dushanbe,7487489,143100.0
221+
Tokelau,None,1466,10.0
222+
East Timor,Dili,1154625,15007.0
223+
Turkmenistan,Ashgabat,4940916,488100.0
224+
Tunisia,Tunis,10589025,163610.0
225+
Tonga,Nuku'alofa,122580,748.0
226+
Turkey,Ankara,77804122,780580.0
227+
Trinidad and Tobago,Port of Spain,1228691,5128.0
228+
Tuvalu,Funafuti,10472,26.0
229+
Taiwan,Taipei,22894384,35980.0
230+
Tanzania,Dodoma,41892895,945087.0
231+
Ukraine,Kiev,45415596,603700.0
232+
Uganda,Kampala,33398682,236040.0
233+
U.S. Minor Outlying Islands,None,0,0.0
234+
United States,Washington,310232863,9629091.0
235+
Uruguay,Montevideo,3477000,176220.0
236+
Uzbekistan,Tashkent,27865738,447400.0
237+
Vatican City,Vatican City,921,0.44
238+
Saint Vincent and the Grenadines,Kingstown,104217,389.0
239+
Venezuela,Caracas,27223228,912050.0
240+
British Virgin Islands,Road Town,21730,153.0
241+
U.S. Virgin Islands,Charlotte Amalie,108708,352.0
242+
Vietnam,Hanoi,89571130,329560.0
243+
Vanuatu,Port Vila,221552,12200.0
244+
Wallis and Futuna,Mata-Utu,16025,274.0
245+
Samoa,Apia,192001,2944.0
246+
Kosovo,Pristina,1800000,10908.0
247+
Yemen,Sanaa,23495361,527970.0
248+
Mayotte,Mamoudzou,159042,374.0
249+
South Africa,Pretoria,49000000,1219912.0
250+
Zambia,Lusaka,13460305,752614.0
251+
Zimbabwe,Harare,11651858,390580.0

SeleniumAutomation/WebScraped.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
except: pass
77

88

9+
link = 'https://www.upgrad.com/learn/'
10+
req = requests.get(link)
11+
12+
soup = bs(req.content, 'html5lib')
13+
Carousel_item__UUZAx = soup.findAll('div', attrs = {'class':'Carousel_item__UUZAx'})
14+
15+
916
def save_scrapped(link, sno):
1017
req = requests.get(link)
1118
soup = bs(req.content, 'html5lib')
@@ -33,13 +40,6 @@ def save_scrapped(link, sno):
3340
f.write(text)
3441

3542

36-
link = 'https://www.upgrad.com/learn/'
37-
req = requests.get(link)
38-
39-
soup = bs(req.content, 'html5lib')
40-
Carousel_item__UUZAx = soup.findAll('div', attrs = {'class':'Carousel_item__UUZAx'})
41-
42-
4343
for i in Carousel_item__UUZAx:
4444
for j in i.findAll('a'):
4545

0 commit comments

Comments
 (0)