Electron microscopy
 
soup.find() and soup.find_all()
- Python for Integrated Circuits -
- An Online Book -
Python for Integrated Circuits                                                                                   http://www.globalsino.com/ICs/        


Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix

=================================================================================

============================================

.find(): Return the first tag that matches the search criteria.
         E.g. soup.find("div"): Returns the first "div" tag.
                .find(tag): Find the first occurrence of a tag.
                .find(tag, {attribute: value}): Find the first occurence of a tag, matching on an attribute-value combo.
                .find("div", {"class": "B6fmyf"}) :
                    .find("div", {"class": "B6fmyf"})
.find_all(): Return a list of all tag that matches the search criteria.         
         E.g. soup.find_all("div")
                .find_all (tag, {attribute: value})
ps = soup.find_all("p"):
         ps[0]: Return the first p tag.
         ps[-1]: Return the last p tag.
for p in ps:          
         # Process each p tag from the list with all the p tags.
Match on several attribute = value pairs:
         E.g. web page code:
                <div class="ok" id="ht">
                <div class="no" id="other">
                <div class="no" id="other">
                      Python code:
                           .find("div", {"class" : "ok", "id" : "other"})
                                 Python output:
                                        Found the first pair of "<div class="no" id="other">"
"class" attribute is a special attribute: e.g. multiple words defined in the value of a class attribute are individually searchable:          
         <div class ="Here correct" id = "data value">:
               .find("div", {"class": "Here"}): # Searchable!
               .find("div", {"class: "correct""}): # Searchable!
               .find("div", {"id": "data"}) # Not searchable!
               .find("div", {"id": "data value "}) # Searchable!

============================================

.find() application for webpage: code:          
          Find a specific word in a webpage and count occurrences
Output:         
          Find a specific word in a webpage and count occurrences

============================================

Find a specific a tag on a webpage: code:          
          Find a specific word in a webpage and count occurrences
Output:         
          Find a specific word in a webpage and count occurrences

============================================

Find a specific word in a webpage and count occurrences: code:          
          Find a specific word in a webpage and count occurrences
Output:         
          Find a specific word in a webpage and count occurrences

============================================

Find a specific word in a webpage, count occurrences and then save in a csv file: code:          
          Find a specific word in a webpage and count occurrences
Output:         
          Find a specific word in a webpage and count occurrences

         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         

 

 

 

 

 

 

 

 

 

 

=================================================================================