7.3
In [ ]:
from selenium import webdriver
browser = webdriver.Chrome()
url = 'https://www.cba.am/am/SitePages/Default.aspx'
browser.get(url)
In [5]:
element=browser.find_element_by_css_selector('#ctl00_PlaceHolderMain_g_863d4f31_7343_4804_bedb_aa7f55c1305a_updatePanelctl00_PlaceHolderMain_g_863d4f31_7343_4804_bedb_aa7f55c1305a > li.gray_2 > em:nth-child(3)')
In [7]:
ex_rate=element.text
In [9]:
print 'Official AMD/USD current exchange rate is ' + ' '+ str(ex_rate)
In [29]:
browser.close()
7.3 other version
In [32]:
from selenium import webdriver
browser = webdriver.Chrome()
url = 'https://www.cba.am/am/SitePages/Default.aspx'
browser.get(url)
In [33]:
element = browser.find_element_by_class_name("sett")
element.click()
In [35]:
bot=browser.find_element_by_css_selector('#cur1')
bot.click()
In [36]:
submit = browser.find_element_by_xpath("//*[@onclick='javascript:SaveSettings()']")
submit.click()
In [38]:
ex_rate = browser.find_elements_by_xpath("//em[@class='w_50']")[-1].text
print 'Official AMD/USD current exchange rate is ' + ' '+ str(ex_rate)
In [39]:
browser.close()
7.2
In [10]:
from selenium import webdriver
browser = webdriver.Chrome()
url = 'https://staff.am/en'
browser.get(url)
In [11]:
training=browser.find_element_by_css_selector('#jobsearchform-type > label:nth-child(2) > input[type="radio"]')
training.click()
search=browser.find_element_by_css_selector('#w0 > div > div.col-lg-2.col-sm-2.search-btn > button')
search.click()
In [12]:
list=browser.find_elements_by_class_name("job-list-item")
In [14]:
import re
In [15]:
list_price=[]
for i in list:
m=re.findall('Price:\s+(.+\s*.+)',i.text)
list_price.append(m)
In [16]:
for i in range(len(list_price)):
list_price[i]=list_price[i][0]
In [20]:
page2=browser.find_element_by_css_selector('#job-list-pagination > ul > li:nth-child(3) > a')
page2.click()
In [21]:
price=browser.find_elements_by_class_name("job-list-item")
list_price2=[]
for i in price:
m=re.findall('Price:\s+(.+\s*.+)',i.text)
list_price2.append(m)
list_price2
Out[21]:
In [22]:
for i in range(len(list_price2)):
list_price2[i]=list_price2[i][0]
In [23]:
for i in list_price2:
list_price.append(i)
list_price
Out[23]:
In [24]:
list1=[]
for i in list_price:
k=re.sub("FREE\ne-learning",'0',i)
list1.append(k)
In [25]:
list2=[]
for i in list1:
k=re.sub("AMD\n.+",'',i)
list2.append(k)
In [27]:
n=len(list2)
sum=0
for i in list2:
p=float(i)
sum=sum+p
In [28]:
average=sum/n
print "Average training price is " +str(average)+" AMD"
In [ ]:
browser.close()
7.1
In [1]:
from selenium import webdriver
browser = webdriver.Chrome()
url = 'http://rate.am/en/armenian-dram-exchange-rates/banks/non-cash'
browser.get(url)
In [2]:
import pandas as pd
In [8]:
data_table = pd.read_html(browser.find_element_by_class_name("rb").get_attribute('outerHTML'))
In [9]:
data_table = data_table[0]
data_table = data_table[2:19]
del data_table[0]
del data_table[2]
del data_table[3]
data_table.columns = ["Bank", "Date", "USD_buy", "USD_sell", "EUR_buy", "EUR_sell", "RUB_buy", "RUB_sell", "GBF_buy", "GBF_sell"]
In [11]:
with open('ex_rates_data.csv', 'w') as f:
data_table.to_csv(f, header=True, index=False)
In [30]:
data_table
Out[30]:
In [13]:
browser.close()
7.1 for July20
In [1]:
from selenium import webdriver
browser = webdriver.Chrome()
url = 'http://rate.am/en/armenian-dram-exchange-rates/banks/non-cash'
browser.get(url)
In [33]:
import pandas as pd
from unicodecsv import *
import csv
In [3]:
date_bot=browser.find_element_by_css_selector('#aspnetForm > div.cnt > div.cnt-body > div.cnt-left > div.rb-de > div.archive > table > tbody > tr > td:nth-child(1) > a')
In [4]:
date_bot.click()
In [5]:
Jul20=browser.find_element_by_css_selector('#calBorder > span > table > tbody > tr:nth-child(3) > td > table > tbody > tr:nth-child(5) > td:nth-child(4)')
Jul20.click()
In [6]:
show=browser.find_element_by_css_selector('#ctl00_Content_RB_dtpick1_btnOk')
show.click()
In [7]:
data_table = pd.read_html(browser.find_element_by_class_name("rb").get_attribute('outerHTMLbrowser.close
In [8]:
data_table = data_table[0]
data_table = data_table[2:19]
del data_table[0]
del data_table[2]
del data_table[3]
data_table.columns = ["Bank", "Date", "USD_buy", "USD_sell", "EUR_buy", "EUR_sell", "RUB_buy", "RUB_sell", "GBF_buy", "GBF_sell"]
In [34]:
with open('ex_rates_July20.csv', 'w') as f:
data_table.to_csv(f, header=True, index=False, encoding="utf-8")
In [35]:
data_table
Out[35]:
In [31]:
browser.close()
In [ ]:
In [ ]:
In [ ]: