Finally, we can wrap everything up in a function that can retrieve the price of any product:
import requests
def getprice(pid):
ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'
url = 'https://www.amazon.com/dp/'+pid
s = requests.get(url, headers={'User-Agent':ua})
pattern = '<span id="priceblock_ourprice" class="a-size-medium a-color-price">$'
price = float( s.text.split(pattern)[-1].split('</span>')[0] )
return price
getprice('B0027YPQEC')
Download this list of English words: http://www.acsu.buffalo.edu/~danet/Sp18/MTH448/class1/class1_files/words.txt
Note that set-membership can be tested much faster than list membership.
The file is at
http://www.acsu.buffalo.edu/~danet/Sp18/MTH448/class2/class2_files/political_transcript.txt
Some questions to answer:
Note: Might want to remove punctuation first.
https://www.ssa.gov/oact/babynames/limits.html
Think about what you'd like to do, and let me know next week.