-
-
Save gka/2134441 to your computer and use it in GitHub Desktop.
BeautifulSoup4 test run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
url = "https://www.cia.gov/library/publications/the-world-factbook/rankorder/2119rank.html" | |
s = BeautifulSoup(requests.get(url).text) | |
for o in s.find(id='countryCode').find_all('option'): | |
code = o.get('value') | |
name = o.get_text() | |
print code, name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xx World | |
af Afghanistan | |
ax Akrotiri | |
al Albania | |
ag Algeria | |
aq American Samoa | |
an Andorra | |
ao Angola | |
av Anguilla | |
ay Antarctica | |
ac Antigua and Barbuda | |
xq Arctic Ocean | |
ar Argentina | |
am Armenia | |
aa Aruba | |
at Ashmore and Cartier Islands | |
zh Atlantic Ocean | |
as Australia | |
au Austria | |
aj Azerbaijan | |
bf Bahamas, The | |
ba Bahrain | |
um Baker Island | |
bg Bangladesh | |
bb Barbados | |
bo Belarus | |
be Belgium | |
bh Belize | |
bn Benin | |
bd Bermuda | |
bt Bhutan | |
bl Bolivia | |
bk Bosnia and Herzegovina | |
bc Botswana | |
bv Bouvet Island | |
br Brazil | |
io British Indian Ocean Territory | |
vi British Virgin Islands | |
bx Brunei | |
bu Bulgaria | |
uv Burkina Faso | |
bm Burma | |
by Burundi | |
cb Cambodia | |
cm Cameroon | |
ca Canada | |
cv Cape Verde | |
cj Cayman Islands | |
ct Central African Republic | |
cd Chad | |
ci Chile | |
ch China | |
kt Christmas Island | |
ip Clipperton Island | |
ck Cocos (Keeling) Islands | |
co Colombia | |
cn Comoros | |
cg Congo, Democratic Republic of the | |
cf Congo, Republic of the | |
cw Cook Islands | |
cr Coral Sea Islands | |
cs Costa Rica | |
iv Cote d'Ivoire | |
hr Croatia | |
cu Cuba | |
cc Curacao | |
cy Cyprus | |
ez Czech Republic | |
da Denmark | |
dx Dhekelia | |
dj Djibouti | |
do Dominica | |
dr Dominican Republic | |
ec Ecuador | |
eg Egypt | |
es El Salvador | |
ek Equatorial Guinea | |
er Eritrea | |
en Estonia | |
et Ethiopia | |
fk Falkland Islands (Islas Malvinas) | |
fo Faroe Islands | |
fj Fiji | |
fi Finland | |
fr France |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment