Hello there!
For my computer studies, I recieved homework where I have to pick any simple computer task and offer a solution on how to create a program for its automatisation in either Flowgorithm or Python. I can either write my own script, or analyze and explain one I've pulled from the internet. After much consideration, I chose this one: Get the Geo Location of an IP Address
Now, our class hasn't done anything but the basic statements and core principals of Python, so I'm having a bit of trouble understanding what most of this means and would greatly appreciate anyone giving me a hand.
paragraph = soup('p')[3]
I believe that this line is about BeautifulSoup finding the correct paragraph with the location information, which is the third one?
If anyone could walk me through this or even just point me in the right direction, I would greatly appreciate it.
Cheers
For my computer studies, I recieved homework where I have to pick any simple computer task and offer a solution on how to create a program for its automatisation in either Flowgorithm or Python. I can either write my own script, or analyze and explain one I've pulled from the internet. After much consideration, I chose this one: Get the Geo Location of an IP Address
Now, our class hasn't done anything but the basic statements and core principals of Python, so I'm having a bit of trouble understanding what most of this means and would greatly appreciate anyone giving me a hand.
if len(sys.argv)!=2: print(usage) sys.exit(0) if len(sys.argv) > 1: ipaddr = sys.argv[1]This is the main culprit, namely I don't understand what the role of !=2 and >1 is supposed to be.
paragraph = soup('p')[3]
I believe that this line is about BeautifulSoup finding the correct paragraph with the location information, which is the third one?
geo_txt = re.sub(r'<.*?>', '', str(paragraph)) print geo_txt[32:].strip()This is where a regex is used to remove the HTML tag, but I can't fathom how to explain what (r'<.*?>', '', str(paragraph)) and print geo_txt[32:].strip() are supposed to mean.
If anyone could walk me through this or even just point me in the right direction, I would greatly appreciate it.
Cheers