python web scraping-get elements in bulk

Web scraping with Python-Introduction- [First step to improve work efficiency] 9-10 Study memo https://www.udemy.com/course/python-scraping-beginner/ Page to be scraped (with PW restrictions) https://scraping-for-beginner.herokuapp.com/mypage

Requirement: Get all the text information on the right side of the table below

image.png

If you press F12 and check with the development tools, you can see that all the text on the right is marked up with td. image.png

1. Get the td element from the browser.

elems_td = browser.find_elements_by_tag_name('td')

2. Take elements one by one from td and put them in value

Put the information of elems_td that got all the elements of td into elem_td.

values = []
#elems_Take out the elements one by one from td and elem_Put in td
for elem_td in elems_td:

3. Put the element (text format) of elem_td in value.

    #elem_Element of td(text format)In value
    value = elem_td.text

4. Add all value elements to the list of values

    #Add all value elements to the list of values
    values.append(value)

All code

#Get td element from browser
elems_td = browser.find_elements_by_tag_name('td')
values = []
#elems_Take out the elements one by one from td and elem_Put in td
for elem_td in elems_td:
    #elem_Element of td(text format)In value
    value = elem_td.text
    #Add all value elements to the list of values
    values.append(value)
#Hit values
values

result

['Kohei Imanishi', 'Kikagaku Co., Ltd.', 'July 15, 1994', 'Chiba', 'basketball\n reading\n Gadget collection']

Recommended Posts

python web scraping-get elements in bulk
Web scraping notes in python3
Getting list elements in Python
Web application development memo in python
Hit the web API in Python
Delete multiple elements in python list
web coder tried excel in Python
Bulk replacement of strings in Python arrays
[Python] Combine all the elements in the array
Quadtree in Python --2
Python in optimization
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Convert PDFs to images in bulk with Python
Rewriting elements in a loop of lists (Python)
Steps to develop a web application in Python
Randomly select elements from list (array) in python
Sort list elements in a specified order in Python
Get only articles from web pages in Python
[Python] Manipulating elements in a list (array) [Sort]
How to remove duplicate elements in Python3 list
Sorted list in Python
Daily AtCoder # 36 in Python