I want to do web scraping.
https://www.aaa.* (*changes from 1 to 10.)
Suppose you have a site called
Some of the above URL sites are
There is a table,
Suppose there is no table.
Change the end of the URL and load sites 1 to 10
I want to extract only sites with tables.
from bs4 import BeautifulSoup import requests import pandas as pd from pandas import Series, DataFrame import time from itertools import product RN =  data = range (1,11) for i in data: time.sleep (3) url = 'https: //www.aaa.'+str (i) result = requests.get (url) c = result.content soup = BeautifulSoup (c, 'lxml') summary = soup.find ('div') table = summary.find_all ('table') if not 'table': # ** (1) ** if summary is None: continue rows = table  .find_all ('tr')
(1) If table is not in the site, I would like to stop the following processing and proceed to the next step.
If there is no table in the site, the following error will appear.
AttributeError:'NoneType'object has no attribute'find_all'
Can you tell me how to write a basic conditional expression?
Answer # 1
I would like you to investigate
formore specifically, but use
continueto skip the iteration and go to the next step. The
if len (table) == 0: continue
Answer # 2
when there is no TABLE tag. Will you be?
for i in Round: time.sleep (3) url = 'https: //www.aaa.'+str (i) result = requests.get (url) c = result.content soup = BeautifulSoup (c, 'lxml') summary = soup.find ('div') table = summary.find_all ('table') if not table: continue rows = table  .find_all ('tr')
- about list creation by web scraping using python library
- python - about sytemctl using error snap in slurm
- about repeated operations in python for statement
- python - analyze financial statement data using pandas
- about output to excel using python openpyxl library
- about scraping in python
- python scraping: error when turning for statement from url list
- python 3x - i want to do scraping using selenium
- [python3] i want to use if statement in integration using sympy
- [python] i want to add a column using the for statement in sqlite and insert data in the last column
- python - about acquisition of elements using beautiful soup
- python - questions about how to aggregate using pandas
- python - image recognition using the created cascade classifier
- python - about the error "allocation of 536870912 exceeds 10% of system memory" when learning cnn
- about list behavior in python
- [python] about atcoder arc006b
- python - goo japanese dictionary scraping
- python - about a problem of satcoder agc39
- [python] about aoj-0105 book index
- python - about importing intertools
- python 3x - typeerror: 'method' object is not subscriptable
- python - you may need to restart the kernel to use updated packages error
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - emulator: dsound: could not initialize about the error message directsoundcapture
- android studio - unresolved reference comes out in kotlin
- mysql startup failed [error] innodb: the innodb_system data file 'ibdata1' must be writable
- django - oserror: [winerror 123] the file name, directory name, or volume label syntax is incorrect : '<frozen importlib_boot
- python - importerror: cannot import name md5 error cannot be resolved