Purple exclamation mark.svg Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.

Red exclamation mark.svg UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.

Python:CIAexchangeRate.py

From Botwiki
Jump to: navigation, search
#GET THE LIST OF COUNTRIES FROM CIA WORLD FACTBOOK - CIAworldfactbooklist1.py
#GET EXCHANAGE RATE - currencyCIA1.py
#PRINT IT ON SOME SANDBOX FILE
 
###SETTINGS
outputPage = u'Wikipedia:CIA 世界概況/洭率'
shortcutPage = 'WP:CIA/EX'
shortcut=shortcutPage
print shortcut
 
import re
import wikipedia
import CIAworldfactbooklist1
import currencyCIA1
 
### TO GET listexchangerate ###
 
def codeCountryExchangeRate():
 
  ### GET THE CODE AND COUNTRY LISTS 
  numberOfCountries, listCode , listCountry = CIAworldfactbooklist1.CIAworldfactbooklist()
 
  ### GET THE EXCHANGE RATES
  listExchangeRate={}
  for n in range(0,numberOfCountries):
    listExchangeRate[n] = currencyCIA1.exchangeRate(listCode[n])
  return numberOfCountries, listCode, listCountry, listExchangeRate
 
 
### HERE RUNS THE PROGRAMME
# CREATE THE SITE OBJECT
 
site=wikipedia.getSite()
 
#GET THE LISTS: CODE, COUNTRY, EXCHANGERATE
numberOfCountries, list1 , list2, list3 = codeCountryExchangeRate()
print numberOfCountries, list1,list2, list3
x=raw_input('wait:')
#MAKE THE OUTPUT STRING
 
text = u'捷徑[[' + shortcutPage + u']][[Category:世界概況]]\n'
 
for n in range(1,numberOfCountries):   # xx = world ! NO CURRENCY!
 if list3[n]==None: continue
 print(list1[n] + ',' + list2[n] + ',' + list3[n] + '\n')
 text += list1[n]+ ',' + list2[n] + ',' + list3[n] + '\n'
 n +=1
 
#PUT THE STRING
sand = wikipedia.Page(site , outputPage)
sand.put( text, u'[[中央情報局]][[世界概況]]([[The World Factbook]]):洭率,由 https://www.cia.gov/library/publications/the-world-factbook/geos/(+countrycode+).htmlHTML - CIAexchangeRate.py')
 
#CREATE A SHORT CUT
short = wikipedia.Page(site, shortcutPage)
short.put( '#REDIRECT [[' + outputPage + ']]' )
 
#STOP
wikipedia.stopme()
Personal tools
Share