python - wget ends at ampersand(&) and skips eveything after that -


wget skips after ampersand(&) tried escaping \& not working

code:

import threading import urllib.request import os import re import time import json import sys  def take():     = ["https://itunes.apple.com/us/genre/ios-games-action/id7001?mt=8&letter=a","https://itunes.apple.com/us/genre/ios-games-action/id7001?mt=8&letter=b"]     url_file in a:         url_file = re.sub(r'\&','\&',url_file)         data = os.popen('wget -qo- %s'% url_file).read()         if re.search(r'(?mis)paginate\-more\">next',data):             print ("hi")   take() 

this should print "hi"

but since wget skips after & thorwing blank output.

how make work?

the problem facing & has special meaning in shell (and calling shell via popen): background job on left-hand side of ampersand.

to circumvent this, have escape special characters, or use quotes around url:

 data = os.popen('wget -qo- "%s"' % url_file).read() 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -