BeautifulSoup.find_all


Definition
The return with the find search in the content.

Syntax
BeautifulSoup.find_all()

Parameters
String/Number

Examples
The web contents are scrapped through BueatifulSoup4 through for loop.
 >>> from bs4 import BeautifulSoup
>>> import requests
>>> r=requests.get('http://www.pythonlake.com/contactus')
>>> b=BeautifulSoup(r.content)
>>> for link in b.find_all('a'):
...     link.get('href')
... 
'http://www.pythonlake.com/'
'/home'
'/aboutus'
'/download'
'/appointment'
'/Contactus'
'/system/app/pages/sitemap/hierarchy'
'/home'
'/beautifulsoup4'
'/boolean'
'/if'
'/while'
'/strisprintable'
'/strisnumeric'
'/strisalpha'
'/strisdigit'
'/setissuperset'
'/setisdisjoint'
'/setissubset'
'/decimalis_finite'
'/decimalis_normal'
'/decimalis_nan'
'/decimalis_nan'
'/decimalis_canonical'
'/decimalis_signed'
'/decimalis_subnormal'
'/decimalis_snan'
'/decimalis_infinite'
'/built-in'
'/abs'
'/bin'
'/bool'
'/bytearray'
'/chr'
'/complex'
'/countstr'
'/dir'
'/divmod'
'/enumerate'
'/float'
'/hex'
'/int'
'/input'
'/len'
'/max'
'/min'
'/ord'
'/range'
'/round'
'/pow'
'/print'
'/slice'
'/sorted'
'/sum'
'/type'
'/control-flow'
'/break'
'/continue'
'/next'
'/def'
'/except'
'/for'
'/if'
'/lambda'
'/pass'
'/while'
'/try'
'/dictionary'
'/dictclear'
'/dictcopy'
'/dictfromkeys'
'/dictget'
'/dictitems'
'/dictkeys'
'/dictpop'
'/dictpopitem'
'/dictsetdefault'
'/dictupdate'
'/dictvalues'
'/decimal'
'/decimaladjusted'
'/decimalas_tuple'
'/decimalcanonical'
'/decimalcompare'
'/decimalcompare_signal'
'/decimalcompare_total'
'/decimalcompare_total_mag'
'/decimalconjugate'
'/decimalcopy_abs'
'/decimalcopy_negate'
'/decimalcopy_sign'
'/decimalexp'
'/decimalfma'
'/decimalfrom_float'
'/decimalimag'
'/decimalis_canonical'
'/decimalis_finite'
'/decimalis_nan'
'/decimalis_normal'
'/decimalis_qnan'
'/decimalis_signed'
'/decimalsubnormal'
'/decimalis_zero'
'/decimalln'
'/decimallog10'
'/decimallogb'
'/decimallogical_and'
'/decimallogical_invert'
'/decimallogical_or'
'/decimallogical_xor'
'/decimalmax'
'/decimalmax_mag'
'/decimalmin_mag'
'/decimalnext_plus'
'/decimalnext_toward'
'/decimalnormalize'
'/decimalnumber_class'
'/decimalquantize'
'/decimalradix'
'/decimalreal'
'/decimalremainder_near'
'/decimalrotate'
'/decimalsame_quantum'
'/decimalscaleb'
'/decimalshift'
'/decimalsqrt'
'/decimalto_eng_string'
'/decimalto_integral'
'/decimalto_integral_exact'
'/decimalto_integral_value'
'/frozenset'
'/frozensetcopy'
'/frozensetdifference'
'/frozensetintersection'
'/frozensetisdisjoint'
'/frozensetissubset'
'/frozensetissuperset'
'/frozensetsymmetric_difference'
'/frozensetunion'
'/fractions'
'/fractionsfraction'
'/fractionsgcd'
'/fraction'
'/fractionconjugate'
'/fractiondenominator'
'/fractionfrom_decimal'
'/fractionfrom_float'
'/fractionimag'
'/fractionlimit_denominator'
'/fractionnumerator'
'/fractionreal'
'/integer'
'/int-bit_length'
'/int-conjugate'
'/int-denominator'
'/int-from_bytes'
'/intimag'
'/intnumerator'
'/intreal'
'/intto_bytes'
'/keywords'
'/and'
'/as'
'/assert'
'/break'
'/class'
'/continue'
'/del'
'/def'
'/else'
'/elif'
'/exec'
'/except'
'/finally'
'/for'
'/from'
'/global'
'/if'
'/import'
'/in'
'/is'
'/lambda'
'/not'
'/or'
'/pass'
'/print'
'/raise'
'/return'
'/try'
'/while'
'/with'
'/yield'
'/list'
'/listappend'
'/listclear'
'/listcount'
'/listcopy'
'/listextend'
'/listinsert'
'/listreverse'
'/listpop'
'/listsort'
'/itertools'
'/itertoolsaccumulate'
'/itertoolschain'
'/itertoolscombinations'
'/itertoolscombinations_with_replacement'
'/itertoolscompress'
'/itertoolscount'
'/itertoolscycle'
'/itertoolsdropwhile'
'/itertoolsfilterfalse'
'/itertoolsgroupby'
'/itertoolsislice'
'/itertoolspermutations'
'/itertoolsproduct'
'/itertoolsrepeat'
'/itertoolsstarmap'
'/itertoolstakewhile'
'/itertoolstee'
'/itertoolszip_longest'
'/math'
'/mathacos'
'/math-acosh'
'/mathasin'
'/mathasinh'
'/mathatan'
'/mathatan2'
'/mathatanh'
'/ceil'
'/mathcopysign'
'/mathcos'
'/mathcosh'
'/mathe'
'/matherf'
'/mathdegrees'
'/math-exp'
'/mathexpm1'
'/mathfabs'
'/math-factorial'
'/mathfloor'
'/mathfmod'
'/mathfrexp'
'/mathfsum'
'/mathgamma'
'/mathisfinite'
'/mathisinf'
'/mathldexp'
'/mathlog10'
'/mathlog1p'
'/mathlog'
'/mathlog2'
'/mathmodf'
'/mathpi'
'/mathpow'
'/mathradians'
'/mathsin'
'/mathsinh'
'/mathsqrt'
'/mathtan'
'/mathtanh'
'/mathtrunc'
'/operators'
'/operatorabs'
'/operatoradd'
'/operatorand_'
'/operatorconcat'
'/operatorcontains'
'/operatordelitem'
'/operatoreq'
'/operatorfloordiv'
'/operatorge'
'/operatorgetitem'
'/operatorgt'
'/operatoriadd'
'/operatoriconcat'
'/operatorifloordiv'
'/operatorilshift'
'/operatorimod'
'/operatorimul'
'/operatorindex'
'/operatorindexof'
'/operatorinv'
'/operatoripow'
'/operatorirshift'
'/operatoris_'
'/operatorisub'
'/operatoritruediv'
'/operatorixor'
'/operatorlength_hint'
'/operatorlshift'
'/operatormod'
'/operatormul'
'/operatorne'
'/operatornot_'
'/operatoror_'
'/operatorpos'
'/operatorsub'
'/operatortruediv'
'/operatortruth'
'/operatorxor'
'/math/random'
'/randomrandom'
'/randomsystemrandom'
'/randombetavariate'
'/randomchoice'
'/randomexpovariate'
'/randomgammavariate'
'/randomgauss'
'/randomgetrandbits'
'/randomgetstate'
'/randomlognormvariate'
'/randomnormalvariate'
'/randomparetovariate'
'/randomrandint'
'/randomrandom-1'
'/randomrandrange'
'/randomsample'
'/randomseed'
'/randomsetstate'
'/randomshuffle'
'/randomtriangular'
'/randomvonmisesvariate'
'/randomweibullvariate'
'/requests'
'/requestsconnectionerror'
'/requestscerts'
'/requestshttperror'
'/requestshead'
'/requestsget'
'/requestsgetheaders'
'/requestsgettext'
'/requestsgetparameters'
'/requestsrequest-1'
'/requestsstatus_codes'
'/set'
'/setadd'
'/setclear'
'/setdifference'
'/setdifference_update'
'/setintersection_update'
'/setisdisjoint'
'/setdiscard'
'/setintersection'
'/setissuperset'
'/setissubset'
'/setpop'
'/setremove'
'/setsymmetric_difference'
'/setsymmetric_difference_update'
'/setunion'
'/setupdate'
'/sqlite3'
'/sqlite3connect'
'/string'
'/strcapitalize'
'/strcasefold'
'/strcenter'
'/strcount'
'/strencode'
'/strendswith'
'/strexpandtabs'
'/strfind'
'/strformat'
'/strformat_map'
'/strindex'
'/strisalnum'
'/strisalpha'
'/strisdecimal'
'/strisdigit'
'/strisidentifier'
'/strlower'
'/strisnumeric'
'/strisprintable'
'/strisspace'
'/stristitle'
'/strisupper'
'/strljust'
'/strjoin'
'/strlstrip'
'/strmaketrans'
'/strsplit'
'/strpartition'
'/strpartition'
'/strsplitlines'
'/strreplace'
'/strrfind'
'/strrstrip'
'/strrindex'
'/strrjust'
'/strrpartition'
'/strrsplit'
'/strswapcase'
'/strstartswith'
'/strtranslate'
'/strupper'
'/strzfill'
'/string-constants'
'/stringascii_letters'
'/stringascii_lowercase'
'/stringascii_uppercase'
'/stringchainmap'
'/stringdigits'
'/stringhexdigits'
'/stringtemplate'
'/stringoctdigits'
'/stringprintable'
'/stringwhitespace'
'/time'
'/timealtzone'
'/timeasctime'
'/timeclock'
'/timectime'
'/timedaylight'
'/timeget_clock_info'
'/timegmtime'
'/timelocaltime'
'/timemonotonic'
'/timeperf_counter'
'/timeprocess_time'
'/timesleep'
'/timestrftime'
'/timestruct_time'
'/timetime'
'/timetimezone'
'/timetzname'
'/tuple'
'/tuplecount'
'/tupleindex'
'/tkinter'
'/tkinterarc'
'/tkinterboth'
'/tkinterbottom'
'/tkinterbutton'
'/tkinterbuttontext'
'/tkinterbuttonpack'
'/tkinterbuttonwidth'
'/tkinterbuttongrid'
'/tkinterbuttongridcolumn'
'/tkinterbuttongridcolumnspan'
'/tkinterbuttoncommand'
'/tkinterbuttongridrow'
'/tkinterbuttonfg'
'/tkinterbuttonpack'
'/tkinterbuttondestroy'
'/tkintercanvas'
'/tkintercanvascreate_line'
'/tkintercanvasheight'
'/tkintercanvaswidth'
'/tkintercanvasbind'
'/tkintercanvascreate_arc'
'/tkintercanvascreate_oval'
'/tkintercanvascreate_ovalsfill'
'/canvaspack'
'/tkintercheckbutton-1'
'/tkintercheckbuttongrid'
'/tkintercheckbuttonpack'
'/tkintere'
'/tkinterentry'
'/tkinterentrydelete'
'/tkinterentrydestroy'
'/tkinterentrygrid'
'/tkinterentryget'
'/tkinterentrypack'
'/tkinterentryget'
'/tkinterentryset'
'/tkinterentrytextvariable'
'/tkinterentrygridcolumnspan'
'/tkinterframe'
'/tkinterframepack'
'/tkinterframewidth'
'/tkinterframeheight'
'/tkinterframebackground'
'/tkinterframebind'
'/tkinterframepack'
'/tkinterframegrid'
'/tkinterleft'
'/tkinterlistbox'
'/tkinterlabel'
'/tkinterlabelbackground'
'/tkinterlabelfg'
'/tkinterlabeltext'
'/tkinterlabelpack'
'/tkinterlabelgrid'
'/tkinterlabelframe'
'/tkinterlabelframetext'
'/tkinterlabelframefg'
'/tkinterlabelframefont'
'/tkinterlabelframepack'
'/tkinterlistbox'
'/tkinterlistboxbackground'
'/tkinterlistboxfg'
'/tkinterlistboxselectbackground'
'/tkinterlistboxhighlightcolor'
'/tkinterlistboxgrid'
'/tkinterlistboxinsert'
'/tkintermenubutton'
'/tkintermenu'
'/tkintermenuadd_command'
'/tkintermessage'
'/tkintermessagepack'
'/tkintermessagegrid'
'/tkintermessagebox'
'/tkintermessageboxshowinfo'
'/tkintern'
'/tkinterne'
'/tkinternw'
'/tkinteroptionmenu'
'/tkinteroptionmenupack'
'/tkinteroptionmenuvariableset'
'/tkinterright'
'/tkinterradiobutton'
'/tkinters'
'/tkinterstringvar'
'/tkinterspinbox'
'/tkinterspinboxfg'
'/tkinterspinboxfrom_'
'/tkinterspinboxto'
'/tkinterspinboxvalues'
'/tkinterspinboxpack'
'/tkinterstringvar'
'/tkinterse'
'/tkintersw'
'/tkintertext'
'/tkintertextpack'
'/tkintertk'
'/tkintertkbind'
'/tkintertkbindbuttonpress'
'/tkintertkconfig'
'/tkintertkdestroy'
'/tkintertkmainloop'
'/tkintertktitle'
'/tkintertkgeometry'
'/tkintertop'
'/tkinterw'
'/webbrowser'
'/webbrowsererror'
'/webbrowserget'
'/webbrowserget'
'/webbrowseropen'
'/webbrowseropen_new'
'/webbrowseropen_new_tab'
'/webbrowserregister'
'/turtle'
'/turtleback'
'/turtlebackward'
'/turtlebegin_fill'
'/turtlebegin_poly'
'/turtlebgcolor'
'/turtlebgpic'
'/turtlebk'
'/turtlebye'
'/turtlecircle'
'/turtleclear'
'/turtleclearscreen'
'/turtleclearstamp'
'/turtleclone'
'/turtlecolor'
'/turtlecolormode'
'/turtledegrees'
'/turtledelay'
'/turtledistance'
'/turtledone'
'/turtledot'
'/turtledown'
'/turtleend_fill'
'/turtleend_poly'
'/turtleexitonclick'
'/turtlefd'
'/turtlefillcolor'
'/turtlefillcolor'
'/turtlefilling'
'/turtleforward'
'/turtleget_poly'
'/turtlegetcanvas'
'/turtlegetpen'
'/turtlegetscreen'
'/turtlegetshapes'
'/turtlegetturtle'
'/turtlegoto'
'/turtleheading'
'/turtlehideturtle'
'/turtlehome'
'/turtleht'
'/turtleisdown'
'/turtleisvisible'
'/turtleleft'
'/turtlelisten'
'/turtlelt'
'/turtlemainloop'
'/turtlemode'
'/turtlenuminput'
'/turtleonclick'
'/turtleondrag'
'/turtleonkey'
'/turtleonrelease'
'/turtleonscreenclick'
'/turtleontimer'
'/turtlepd'
'/turtlepen-1'
'/turtlepencolor'
'/turtlepensize'
'/turtlepenup'
'/operatorpos'
'/turtleposition'
'/turtlepu'
'/turtleradians'
'/turtleregister_shape'
'/turtlereset'
'/turtleresetscreen'
'/turtleresizemode'
'/turtleright'
'/turtlert'
'/turtlescreensize'
'/turtleseth'
'/turtlesetheading'
'/turtlesetpos'
'/turtlesetworldcoordinates'
'/turtlesetx'
'/turtlesety'
'/turtleshape-1'
'/turtleshapetransform'
'/turtleshearfactor'
'/turtleshowturtle'
'/turtlespeed'
'/turtlest'
'/turtlestamp'
'/turtletextinput'
'/turtletilt'
'/turtletitle'
'/turtletiltangle'
'/turtletowards'
'/turtletracer'
'/turtleturtles'
'/turtleturtlesize'
'/turtleundo'
'/turtleundobufferentries'
'/turtleup'
'/turtleupdate'
'/turtlewidth'
'/turtlewindow_width'
'/turtlewindow_height'
'/turtlewrite'
'/turtlewrite_docstringdict'
'/turtleycor'
'/turtlexcor'
'/system'
'/system/errors'
'/Contactus'
'/sitemap.xml'
'/requestsstatus_codes'
'http://www.pythonlake.com/aboutus'
'http://www.pythonlake.com/Contactus'
'http://www.pythonlake.com/appointment'
'http://www.pythonlake.com/download'
'http://www.pythonlake.com/operators'
'http://www.pythonlake.com/keywords'
'http://www.pythonlake.com/built-in'
'http://www.pythonlake.com/boolean'
'http://www.pythonlake.com/dictionary'
'http://www.pythonlake.com/math'
'http://www.pythonlake.com/integer'
'http://www.pythonlake.com/decimal'
'http://www.pythonlake.com/math/random'
'http://www.pythonlake.com/requests'
'http://www.pythonlake.com/set'
'http://www.pythonlake.com/frozenset'
'http://www.pythonlake.com/list'
'http://www.pythonlake.com/tuple'
'http://www.pythonlake.com/fractions'
'http://www.pythonlake.com/fraction'
'http://www.pythonlake.com/string'
'http://www.pythonlake.com/string-constants'
'http://www.pythonlake.com/control-flow'
'http://www.pythonlake.com/itertools'
'http://www.pythonlake.com/time'
'http://www.pythonlake.com/tkinter'
'http://www.pythonlake.com/turtle'
'http://www.pythonlake.com/system/app/pages/sitemap/hierarchy'
'https://www.google.com/a/UniversalLogin?service=jotspot&continue=http://sites.google.com/a/pythonlake.com/www/contactus'



 The requests get contents from the jseditor.org and beautiful extract the select tag with id attributes.
 import requests
r = requests.get('http://jseditor.org/')
from bs4 import BeautifulSoup
soup=BeautifulSoup(r.content, "lxml")
print(soup.find_all("select", attrs={"id": "select"}))
 output here is:
 ============== RESTART: C:/Users/Mishal Emaan/Desktop/output.py ==============
[<select class="form-control" id="select" onchange="selectTheme()">
<option selected="">default</option>
<option>3024-day</option>
<option>3024-night</option>
<option>abcdef</option>
<option>ambiance</option>
<option>base16-dark</option>
<option>base16-light</option>
<option>bespin</option>
<option>blackboard</option>
<option>cobalt</option>
<option>colorforth</option>
<option>dracula</option>
<option>duotone-dark</option>
<option>duotone-light</option>
<option>eclipse</option>
<option>elegant</option>
<option>erlang-dark</option>
<option>hopscotch</option>
<option>icecoder</option>
<option>isotope</option>
<option>lesser-dark</option>
<option>liquibyte</option>
<option>material</option>
<option>mbo</option>
<option>mdn-like</option>
<option>midnight</option>
<option>monokai</option>
<option>neat</option>
<option>neo</option>
<option>night</option>
<option>panda-syntax</option>
<option>paraiso-dark</option>
<option>paraiso-light</option>
<option>pastel-on-dark</option>
<option>railscasts</option>
<option>rubyblue</option>
<option>seti</option>
<option>solarized dark</option>
<option>solarized light</option>
<option>the-matrix</option>
<option>tomorrow-night-bright</option>
<option>tomorrow-night-eighties</option>
<option>ttcn</option>
<option>twilight</option>
<option>vibrant-ink</option>
<option>xq-dark</option>
<option>xq-light</option>
<option>yeti</option>
<option>zenburn</option>
</select>]
>>> 

BeautifulSoup4


Comments