”@

Home 

python Programming Glossary: soup

retrieve links from web page using python and beautiful soup

http://stackoverflow.com/questions/1080411/retrieve-links-from-web-page-using-python-and-beautiful-soup

links from web page using python and beautiful soup How can I retrieve the links of a webpage and copy the url.. of the links using Python python hyperlink beautifulsoup share improve this question Here's a short snippet using..

Beautiful Soup cannot find a CSS class if the object has other classes, too

http://stackoverflow.com/questions/1242755/beautiful-soup-cannot-find-a-css-class-if-the-object-has-other-classes-too

if a page has div class class1 and p class class1 then soup.findAll True 'class1' will find them both. If it has p class.. have other classes too python screen scraping beautifulsoup share improve this question Just in case anybody comes across.. or license for more information. In 1 import bs4 In 2 soup bs4.BeautifulSoup ' div class foo bar div ' In 3 soup attrs..

How to make the python interpreter correctly handle non-ASCII characters in string operations?

http://stackoverflow.com/questions/1342000/how-to-make-the-python-interpreter-correctly-handle-non-ascii-characters-in-stri

bin python2.4 # coding utf 8 The code f urllib.urlopen url soup BeautifulSoup f s soup.find 'div' 'id' 'main_count' #making.. utf 8 The code f urllib.urlopen url soup BeautifulSoup f s soup.find 'div' 'id' 'main_count' #making a print 's' here goes well...

How to download any(!) webpage with correct charset in python?

http://stackoverflow.com/questions/1495627/how-to-download-any-webpage-with-correct-charset-in-python

encoding you pass in as the fromEncoding argument to the soup constructor. An encoding discovered in the document itself for..

Sanitising user input using Python

http://stackoverflow.com/questions/16861/sanitising-user-input-using-python

'href src'.split # Attributes which should have a URL soup BeautifulSoup value for comment in soup.findAll text lambda.. should have a URL soup BeautifulSoup value for comment in soup.findAll text lambda text isinstance text Comment # Get rid of.. Comment # Get rid of comments comment.extract for tag in soup.findAll True if tag.name not in validTags tag.hidden True attrs..

Remove a tag using BeautifulSoup but keep its contents

http://stackoverflow.com/questions/1765848/remove-a-tag-using-beautifulsoup-but-keep-its-contents

Currently I have code that does something like this soup BeautifulSoup value for tag in soup.findAll True if tag.name.. something like this soup BeautifulSoup value for tag in soup.findAll True if tag.name not in VALID_TAGS tag.extract soup.renderContents.. True if tag.name not in VALID_TAGS tag.extract soup.renderContents Except I don't want to throw away the contents..

BeautifulSoup Grab Visible Webpage Text

http://stackoverflow.com/questions/1936466/beautifulsoup-grab-visible-webpage-text

http stackoverflow.com questions 1752662 beautifulsoup easy way to to obtain html free contents that returns lots of.. scripts comments css junk...etc.. python text beautifulsoup html content extraction share improve this question Try.. 'http www.nytimes.com 2009 12 21 us 21storm.html' .read soup BeautifulSoup.BeautifulSoup html texts soup.findAll text True..

Decode HTML entities in Python string?

http://stackoverflow.com/questions/2087370/decode-html-entities-in-python-string

lxml import html from BeautifulSoup import BeautifulSoup soup BeautifulSoup p pound 682m p text soup.find p .string print.. BeautifulSoup soup BeautifulSoup p pound 682m p text soup.find p .string print text pound 682m print html.fromstring text..

Download image file from the HTML page source using python?

http://stackoverflow.com/questions/257409/download-image-file-from-the-html-page-source-using-python

out_folder test Downloads all the images at 'url' to test soup bs urlopen url parsed list urlparse.urlparse url for image in.. urlopen url parsed list urlparse.urlparse url for image in soup.findAll img print Image src s image filename image src .split..

Regular expression to extract URL from an HTML link

http://stackoverflow.com/questions/499345/regular-expression-to-extract-url-from-an-html-link

pretty easy to do from BeautifulSoup import BeautifulSoup soup BeautifulSoup html_to_parse for tag in soup.findAll 'a' href.. BeautifulSoup soup BeautifulSoup html_to_parse for tag in soup.findAll 'a' href True print tag 'href' Once you've installed..

Python regular expression for HTML parsing (BeautifulSoup)

http://stackoverflow.com/questions/55391/python-regular-expression-for-html-parsing-beautifulsoup

open ' yourwebsite page.html' 'r' .read #Create the soup object from the HTML data soup BeautifulSoup html_data fooId.. 'r' .read #Create the soup object from the HTML data soup BeautifulSoup html_data fooId soup.find 'input' name 'fooId'.. from the HTML data soup BeautifulSoup html_data fooId soup.find 'input' name 'fooId' type 'hidden' #Find the proper tag..

Python HTML sanitizer / scrubber / filter

http://stackoverflow.com/questions/699468/python-html-sanitizer-scrubber-filter

'strong' 'em' 'p' 'ul' 'li' 'br' def sanitize_html value soup BeautifulSoup value for tag in soup.findAll True if tag.name.. sanitize_html value soup BeautifulSoup value for tag in soup.findAll True if tag.name not in VALID_TAGS tag.hidden True return.. True if tag.name not in VALID_TAGS tag.hidden True return soup.renderContents If you want to remove the contents of the invalid..

Python and BeautifulSoup encoding issues

http://stackoverflow.com/questions/7219361/python-and-beautifulsoup-encoding-issues

content variable to BeautifulSoup it all gets messed up soup BeautifulSoup content print soup ... a class blogCalendarToday.. it all gets messed up soup BeautifulSoup content print soup ... a class blogCalendarToday href component blog_calendar year.. would be much appreciated. python unicode utf 8 beautifulsoup share improve this question could you try r urllib.urlopen..

Returning a lower case ASCII string from a (possibly encoded) string fetched using urllib2 or BeautifulSoup

http://stackoverflow.com/questions/9012607/returning-a-lower-case-ascii-string-from-a-possibly-encoded-string-fetched-usi

BeautifulSoup with closing urllib2.urlopen URL as page soup BeautifulSoup page print soup text regex.compile ur' fi L keywords.. urllib2.urlopen URL as page soup BeautifulSoup page print soup text regex.compile ur' fi L keywords ' keywords 'your' 'keywords'.. post li and poļ¬ li and poļ¬ li this is ignored ol div ''' soup BeautifulSoup html # remove comments comments soup.findAll text..

Beautiful Soup cannot find a CSS class if the object has other classes, too

http://stackoverflow.com/questions/1242755/beautiful-soup-cannot-find-a-css-class-if-the-object-has-other-classes-too

Soup cannot find a CSS class if the object has other classes too.. Just in case anybody comes across this question. BeautifulSoup now supports this Python 2.7.5 default May 15 2013 22 43 36.. more information. In 1 import bs4 In 2 soup bs4.BeautifulSoup ' div class foo bar div ' In 3 soup attrs 'class' 'bar' Out..

how to submit query to .aspx page in python

http://stackoverflow.com/questions/1480356/how-to-submit-query-to-aspx-page-in-python

HTMLParser or with other modules such as Beautiful Soup The following snippet demonstrates the requesting and receiving..

How to download any(!) webpage with correct charset in python?

http://stackoverflow.com/questions/1495627/how-to-download-any-webpage-with-correct-charset-in-python

Solution I have not tried it yet... According to Beautiful Soup's documentation . Beautiful Soup tries the following encodings.. According to Beautiful Soup's documentation . Beautiful Soup tries the following encodings in order of priority to turn your.. or for HTML documents an http equiv META tag. If Beautiful Soup finds this kind of encoding within the document it parses the..

Best way to decode unknown unicoding encoding in Python 2.5

http://stackoverflow.com/questions/1715772/best-way-to-decode-unknown-unicoding-encoding-in-python-2-5

of Universal Feed Parser UnicodeDammit part of Beautiful Soup chardet is supposed to be a port of the way that firefox does..

Parsing HTML in python - lxml or BeautifulSoup? Which of these is better for what kinds of purposes?

http://stackoverflow.com/questions/1922032/parsing-html-in-python-lxml-or-beautifulsoup-which-of-these-is-better-for-wha

HTML in python lxml or BeautifulSoup Which of these is better for what kinds of purposes From what.. HTML parsing libraries in Python are lxml and BeautifulSoup. I've chosen BeautifulSoup for a project I'm working on but.. in Python are lxml and BeautifulSoup. I've chosen BeautifulSoup for a project I'm working on but I chose it for no particular..

How do I unescape HTML entities in a string in Python 3.1?

http://stackoverflow.com/questions/2360598/how-do-i-unescape-html-entities-in-a-string-in-python-3-1

it in the documentation. YES I've tried to get Beautiful Soup to work MANY TIMES without success in 3.X. If you could provide..

Extracting text from HTML file using Python

http://stackoverflow.com/questions/328356/extracting-text-from-html-file-using-python

formed HTML. I've seen many people recommend Beautiful Soup but I've had a few problems using it. For one it picked up unwanted..

Regex that only matches text that's not part of HTML markup? (python)

http://stackoverflow.com/questions/401726/regex-that-only-matches-text-thats-not-part-of-html-markup-python

anyway if I were you I would have a look at Beautiful Soup which is a Python HTML XML parser . Really there are so many..

Python: Is there a way to determine the encoding of text file?

http://stackoverflow.com/questions/436220/python-is-there-a-way-to-determine-the-encoding-of-text-file

or for HTML documents an http equiv META tag. If Beautiful Soup finds this kind of encoding within the document it parses the..

Beautiful Soup to parse url to get another urls data

http://stackoverflow.com/questions/4462061/beautiful-soup-to-parse-url-to-get-another-urls-data

Soup to parse url to get another urls data I need to parse a url.. share improve this question import urllib2 from BeautifulSoup import BeautifulSoup page urllib2.urlopen 'http yahoo.com' .read.. import urllib2 from BeautifulSoup import BeautifulSoup page urllib2.urlopen 'http yahoo.com' .read soup BeautifulSoup..

utf8' codec can't decode byte 0x96 in python

http://stackoverflow.com/questions/7873556/utf8-codec-cant-decode-byte-0x96-in-python

urllib.urlopen http www.homestead.com page BeautifulSoup ''.join htmlfile print page.prettify now I am getting this error.. page.prettify now I am getting this error page BeautifulSoup ''.join htmlfile TypeError 'module' object is not callable I.. start example from http www.crummy.com software BeautifulSoup documentation.html#Quick 20Start . If I copy paste it then the..

Getting all visible text from a webpage using Selenium

http://stackoverflow.com/questions/7947579/getting-all-visible-text-from-a-webpage-using-selenium

the reason I used Selenium and not Mechanize and Beautiful Soup is because I wanted JavaScript tendered text python xpath webpage..

How do I iterate over the HTML attributes of a Beautiful Soup element?

http://stackoverflow.com/questions/822571/how-do-i-iterate-over-the-html-attributes-of-a-beautiful-soup-element

do I iterate over the HTML attributes of a Beautiful Soup element How do I iterate over the HTML attributes of a Beautiful.. How do I iterate over the HTML attributes of a Beautiful Soup element Like given foo bar asdf blah 123 xyz foo I want bar.. share improve this question from BeautifulSoup import BeautifulSoup page BeautifulSoup ' foo bar asdf blah..