I'm trying to pass an argument in my python script as a URL. But I can't seem to find any way to allow spaces in the argument and take it as a single argument.
My command:
python -W ignore scrape.py --url 'https://www.pinterest.com/search/pins/?q=old city' --fname dat.csv
Error:
usage: scrape.py [-h] [-url URL] [-fname FNAME]
scrape.py: error: unrecognized arguments: city'
Normally, the script works if I have one word after ?q=, but I want to be able to enter multiple words after ?q=.
Tested: As seen in the above command, I tested adding quotes around my URL, but it still doesn't work.
My Python argument script:
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-url", "--url", help="Enter the URL")
parser.add_argument("-fname", "--fname", help="Enter Filename")
args = parser.parse_args()
grab(args.url, args.fname)
if __name__ == "__main__":
main()
Is there anything I can do to be able to enter a URL with spaces in the arguments?
Thanks in advance
scrape.py --url 'https://www.pinterest.com/search/pins/?q=old%20city' --fname dat.csvand @MarkusUnterwaditzer's suggestions