0

Every time I enter two addresses on the command line the addresses get squished together. Also I can't seem to get the page to download using requests. I'm sure it's a simple fix.

import webbrowser, sys, requests

address = ' '.join(sys.argv[1:])
SecondAddress = '  '.join(sys.argv[2:])
webbrowser.open("https://www.google.com/maps/place/"+address)
webbrowser.open("https://www.google.com/maps/dir/"+ address+"/"+SecondAddress)

RES = requests.get ('"https://www.google.com/maps/dir/"+address+"/"+SecondAddress')
output = open("directions.txt", 'wb')
for chunk in RES.iter_content(100000):
   output.write(chunk)
output.close()

1 Answer 1

1

Instead of writing this:

address = ' '.join(sys.argv[1:])
SecondAddress = '  '.join(sys.argv[2:])

Do this:

address = ' '.join(sys.argv[1])
SecondAddress = '  '.join(sys.argv[2])

Also you are not able to download the page using requests because you are not passing an url, you are passing this string: 'https://www.google.com/maps/dir/+address+/+SecondAddress'

Do this:

direction_url = "https://www.google.com/maps/dir/"+address+"/"+SecondAddress
RES = requests.get (direction_url)

Note: Pass both the addresses to the command line with '+' as a separator between each word like this:

python test.py airport+pune phoenix+mall+pune
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.