Soup output is filled with extra spaces?

16 views
Skip to first unread message

zedalp...@gmail.com

unread,
Aug 27, 2015, 12:11:10 PM8/27/15
to beautifulsoup
I'm scraping img files off of several websites and Soup works great most of the time. However, some of the results are filled with spaces ... an example is:

v   a   r       S   E   S   S   I   O   N   U   R   L       =       "   s   =   3   b   e   d   7   f   d   b   e   d   d   2   a   9   b   b   3   0   1   a   e   9   4   c   e   7   4   b   9   a   2   4   &"   ;      
          v   a   r       S   E   C   U   R   I   T   Y   T   O   K   E   N       =       "   g   u   e   s   t   "   ;      
          v   a   r       I   M   G   D   I   R   _   M   I   S   C       =       "   i   m   a   g   e   s   /   m   i   s   c   "   ;      
          v   a   r       I   M   G   D   I   R   _   B   U   T   T   O   N       =       "   i   m   a   g   e   s   /   b   u   t   t   o   n   s   "   ;      
          v   a   r       v   b   _   d   i   s   a   b   l   e   _   a   j   a   x       =       p   a   r   s   e   I   n   t   (   "   0   "   ,       1   0   )   ;      
          v   a   r       S   I   M   P   L   E   V   E   R   S   I   O   N       =       "   4   2   2   "   ;      
          v   a   r       B   B   U   R   L       =       "   h   t   t   p   :   /   /   x   x   x   x   x   x   x   x   x   .   c   o   m   "   ;  

    *** url obfuscated with x's for posting in this forum ***

When I use wget on the same url, I don't get the spaces. This is seriously messing up my program <grin>! I think that the url has some sort of filter on the server-side that detects what I'm trying to do. I've already added the opener code to spoof a browser:

  opener = urllib2.build_opener()
  opener.addheaders = [('User-agent', 'Mozilla/5.0')]
  urlContent=opener.open(url)
#  urlContent = urllib2.urlopen(url).read()
  soup = BeautifulSoup(urlContent)
  imgTags = soup.findAll('img')

Yet still my soup variable content is filled with these spaces.

Any suggestions?

Zedadiah.

P.S. I can provide several example urls if that would be helpful. -ZA
Reply all
Reply to author
Forward
0 new messages