Skip to content

Commit

Permalink
MAINT: remove deprecated usage of BeautifulSoup
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed Jun 15, 2024
1 parent b8df567 commit bafbef8
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions astroquery/alma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,9 +1162,9 @@ def _cycle0_tarfile_content(self):
# <tr width="blah"> which the default parser does not pick up
root = BeautifulSoup(response.content, 'html.parser')
html_table = root.find('table', class_='grid listing')
data = list(zip(*[(x.findAll('td')[0].text,
x.findAll('td')[1].text)
for x in html_table.findAll('tr')]))
data = list(zip(*[(x.find_all('td')[0].text,
x.find_all('td')[1].text)
for x in html_table.find_all('tr')]))
columns = [Column(data=data[0], name='ID'),
Column(data=data[1], name='Files')]
tbl = Table(columns)
Expand Down
2 changes: 1 addition & 1 deletion astroquery/cosmosim/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ def download(self, jobid=None, filename=None, format=None, cache=True):
auth=(self.username, self.password))
soup = BeautifulSoup(results.content, "lxml")
urls = [i.get('xlink:href')
for i in soup.findAll({'uws:result'})]
for i in soup.find_all({'uws:result'})]
formatlist = [urls[i].split('/')[-1].upper()
for i in range(len(urls))]

Expand Down
6 changes: 3 additions & 3 deletions astroquery/eso/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ def list_surveys(self, *, cache=True):
collections_table = root.find('table', id='collections_table')
other_collections = root.find('select', id='collection_name_option')
# it is possible to have empty collections or other collections...
collection_elts = (collections_table.findAll('input', type='checkbox')
collection_elts = (collections_table.find_all('input', type='checkbox')
if collections_table is not None
else [])
other_elts = (other_collections.findAll('option')
other_elts = (other_collections.find_all('option')
if other_collections is not None
else [])
for element in (collection_elts + other_elts):
Expand Down Expand Up @@ -969,7 +969,7 @@ def _print_surveys_help(self, url, *, cache=True):

# hovertext from different labels are used to give more info on forms
helptext_dict = {abbr['title'].split(":")[0].strip(): ":".join(abbr['title'].split(":")[1:])
for abbr in form.findAll('abbr')
for abbr in form.find_all('abbr')
if 'title' in abbr.attrs and ":" in abbr['title']}

for fieldset in form.select('fieldset'):
Expand Down
6 changes: 3 additions & 3 deletions astroquery/ipac/irsa/ibe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def list_missions(self, *, cache=True):
cache=cache)

root = BeautifulSoup(response.text, 'html5lib')
links = root.findAll('a')
links = root.find_all('a')

missions = [os.path.basename(a.attrs['href'].rstrip('/')) for a in links]
self._missions = missions
Expand Down Expand Up @@ -309,7 +309,7 @@ def list_datasets(self, *, mission=None, cache=True):
cache=cache)

root = BeautifulSoup(response.text, 'html5lib')
links = root.findAll('a')
links = root.find_all('a')
datasets = [a.text for a in links
if a.attrs['href'].count('/') >= 4 # shown as '..'; ignore
]
Expand Down Expand Up @@ -364,7 +364,7 @@ def list_tables(self, *, mission=None, dataset=None, cache=True):
cache=cache)

root = BeautifulSoup(response.text, 'html5lib')
return [tr.find('td').string for tr in root.findAll('tr')[1:]]
return [tr.find('td').string for tr in root.find_all('tr')[1:]]

# Unfortunately, the URL construction for each data set is different, and
# they're not obviously accessible via API
Expand Down
2 changes: 1 addition & 1 deletion astroquery/linelists/cdms/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def query_lines_async(self, min_frequency, max_frequency, *,
soup = BeautifulSoup(response.text, 'html.parser')

ok = False
urls = [x.attrs['src'] for x in soup.findAll('frame',)]
urls = [x.attrs['src'] for x in soup.find_all('frame',)]
for url in urls:
if 'tab' in url and 'head' not in url:
ok = True
Expand Down
2 changes: 1 addition & 1 deletion astroquery/simbad/get_votable_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def reload_votable_fields_json():
# Find the first <table> tag that follows it
table = foundtext.findNext('table')
outd = {}
for row in table.findAll('tr'):
for row in table.find_all('tr'):
cols = row.findChildren('td')
if len(cols) > 1:
smallest_child = cols[0].find_all()[-1]
Expand Down
4 changes: 2 additions & 2 deletions astroquery/skyview/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ def survey_dict(self):
response = self._request('GET', self.URL, cache=False)
response.raise_for_status()
page = BeautifulSoup(response.content, "html.parser")
surveys = page.findAll('select', {'name': 'survey'})
surveys = page.find_all('select', {'name': 'survey'})

self._survey_dict = {
sel['id']: [x.text for x in sel.findAll('option')]
sel['id']: [x.text for x in sel.find_all('option')]
for sel in surveys
if 'overlay' not in sel['id']
}
Expand Down
2 changes: 1 addition & 1 deletion astroquery/splatalogue/build_species_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_json_species_ids(*, outfile='splat-species.json', base_url=conf.base_url
result = requests.get(f'{base_url}/b.php')
page = bs4.BeautifulSoup(result.content, 'html5lib')
# The ID needs to be checked periodically if Splatalogue is updated
sid = page.findAll('select', attrs={'id': 'speciesselectbox'})[0]
sid = page.find_all('select', attrs={'id': 'speciesselectbox'})[0]

species_types = set()
for kid in sid.children:
Expand Down
2 changes: 1 addition & 1 deletion astroquery/wfau/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ def _get_databases(self):

root = BeautifulSoup(response.content, features='html5lib')
databases = [xrf.attrs['value'] for xrf in
root.find('select').findAll('option')]
root.find('select').find_all('option')]
return databases

def list_databases(self):
Expand Down

0 comments on commit bafbef8

Please sign in to comment.