User:R. Hillgentleman/CIAexchangeRate.py

出自維基百科,自由嘅百科全書
Jump to navigation Jump to 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()