[Python] Combine all the elements in the array

I'm studying scraping in Python. I wanted to get the value for each page, but I got the value that the class name etc. does not cover. So, this time, I would like to carry out "a strategy of plundering only the part that is a regular expression by combining all the arrays for each page for the time being".

Process

  1. Combine all the elements in the array
  2. Apply a regular expression to the combined one
  3. Collect only the part that matches the regular expression

I want only this ** Japan **

list = ['Hide', 'Hide', 'Hide', 'Hide', 'Hide', 'Japan', 'Hide']

Combine all the elements in the array

list_join = (''.join(list))
print(list_join)
#Hide Hidden Hidden Hidden Hidden Japan Hidden

Apply a regular expression and collect only the part that is

list_join = (''.join(list))
compile = re.compile('[a-zA-Z]+')
print(''.join(compile.findall(list_join)))
# Japan

reference https://murashun.jp/blog/20200113-20.html https://note.nkmk.me/python-re-regex-character-type/

Recommended Posts

[Python] Combine all the elements in the array
[Python] Outputs all combinations of elements in the list
Make sure all the elements in the list are the same in Python
About __all__ in python
[python] Check the elements of the list all, any
Output in the form of a python array
Randomly select elements from list (array) in python
[Python] Manipulating elements in a list (array) [Sort]
Empty multidimensional array in python
Download the file in Python
Find the difference in Python
Get the size (number of elements) of UnionFind in Python
Getting list elements in Python
[Python] Leave only the elements that start with a specific character string in the array
How to swap elements in an array in Python, and how to reverse an array.
Get the number of specific elements in a python list
python web scraping-get elements in bulk
Getting the arXiv API in Python
Save the binary file in Python
Hit the Sesami API in Python
Get the desktop path in Python
Get the script path in Python
In the python command python points to python3.8
Implement the Singleton pattern in Python
Hit the web API in Python
I wrote the queue in Python
Calculate the previous month in Python
Examine the object's class in python
Get the desktop path in Python
Get the host name in Python
Delete multiple elements in python list
Access the Twitter API in Python
The first step in Python Matplotlib
I wrote the stack in Python
Master the weakref module in Python
[Python] Let's reduce the number of elements in the result in set operations
All elements move (do not remain in the same position) shuffle
Determine if all list elements are present in the dict key
Learn the design pattern "Builder" in Python
Load the remote Python SDK in IntelliJ
Try using the Wunderlist API in Python
Check the behavior of destructor in Python
Learn the design pattern "Flyweight" in Python
Try using the Kraken API in Python
Learn the design pattern "Observer" in Python
Learn the design pattern "Memento" in Python
Learn the design pattern "Proxy" in Python
Write the test in a python docstring
Display Python 3 in the browser with MAMP
Learn the design pattern "Visitor" in Python
Read all csv files in the folder
Learn the design pattern "Bridge" in Python
Check if the URL exists in Python
Learn the design pattern "Mediator" in Python
Associate the table set in python models.py
Learn the design pattern "Decorator" in Python
Run the Python interpreter in a script
What is "mahjong" in the Python library? ??
Read the file line by line in Python
MongoDB for the first time in Python
Learn the design pattern "Iterator" in Python