Usetutoringspotscode to get 8% OFF on your first order!

  • time icon24/7 online - support@tutoringspots.com
  • phone icon1-316-444-1378 or 44-141-628-6690
  • login iconLogin

Part 2: Currency Exchange Table Look Up

Part 2: Currency Exchange Table Look Up

In order to calculate the transactions in the later sections, you need to access the currency exchange information. The currency exchange rate table can be found in URL: https://www.cs.purdue.edu/homes/jind/exchangerate.html. In order to access the information, you need to implement a basic web crawler. For this project, your crawler only need to collect currency exchange rate information.
The first thing your crawler should do is to specify the URL you would like to fetch. Then use an URL open function with this request object to return a response object for the URL requested. This response is a file-like object, which means you can call functions such as .read() on the response. Further, it is known that the dominant character encoding for the World Wide Web is UTF-8. Use this registered codec for decoding. To be more specific, you need to define:

#helps fetch currency information from the currency table
#PARAMETERS:
#url: specifies the url you are trying to fetch, type: string, example: “http://www.google.com”
#RETURN: currency information list, type: nested list
def fetch(url):
#Create request object and get web content by given url

#Read the currency exchange table and put the information in a nested list called, e.g. records

#Each element in records will contain the currency name and a list of the exchange rate between USD
#The sublist includes the rate stored in the first column, and the rate stored in the second column of the webpage table
#i.e., records = [[‘Argentine Peso’, [9.44195, 0.10591]], [‘Australian Dollar’, [1.41824, 0.7051]], …]

#In the end, fetch() should return records
#Return records

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Part 2: Currency Exchange Table Look Up

Part 2: Currency Exchange Table Look Up

In order to calculate the transactions in the later sections, you need to access the currency exchange information. The currency exchange rate table can be found in URL: https://www.cs.purdue.edu/homes/jind/exchangerate.html. In order to access the information, you need to implement a basic web crawler. For this project, your crawler only need to collect currency exchange rate information.
The first thing your crawler should do is to specify the URL you would like to fetch. Then use an URL open function with this request object to return a response object for the URL requested. This response is a file-like object, which means you can call functions such as .read() on the response. Further, it is known that the dominant character encoding for the World Wide Web is UTF-8. Use this registered codec for decoding. To be more specific, you need to define:

#helps fetch currency information from the currency table
#PARAMETERS:
#url: specifies the url you are trying to fetch, type: string, example: “http://www.google.com”
#RETURN: currency information list, type: nested list
def fetch(url):
#Create request object and get web content by given url

#Read the currency exchange table and put the information in a nested list called, e.g. records

#Each element in records will contain the currency name and a list of the exchange rate between USD
#The sublist includes the rate stored in the first column, and the rate stored in the second column of the webpage table
#i.e., records = [[‘Argentine Peso’, [9.44195, 0.10591]], [‘Australian Dollar’, [1.41824, 0.7051]], …]

#In the end, fetch() should return records
#Return records

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes