From bafbef83866ceccb37342691a5a8fe7de4067984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Fri, 14 Jun 2024 18:41:38 -0700 Subject: [PATCH] MAINT: remove deprecated usage of BeautifulSoup --- astroquery/alma/core.py | 6 +++--- astroquery/cosmosim/core.py | 2 +- astroquery/eso/core.py | 6 +++--- astroquery/ipac/irsa/ibe/core.py | 6 +++--- astroquery/linelists/cdms/core.py | 2 +- astroquery/simbad/get_votable_fields.py | 2 +- astroquery/skyview/core.py | 4 ++-- astroquery/splatalogue/build_species_table.py | 2 +- astroquery/wfau/core.py | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/astroquery/alma/core.py b/astroquery/alma/core.py index 52adff39e0..99b060f9b5 100644 --- a/astroquery/alma/core.py +++ b/astroquery/alma/core.py @@ -1162,9 +1162,9 @@ def _cycle0_tarfile_content(self): # 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) diff --git a/astroquery/cosmosim/core.py b/astroquery/cosmosim/core.py index c4c735a408..124ab8e7df 100644 --- a/astroquery/cosmosim/core.py +++ b/astroquery/cosmosim/core.py @@ -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))] diff --git a/astroquery/eso/core.py b/astroquery/eso/core.py index 0ba9a33484..421e6fd81a 100644 --- a/astroquery/eso/core.py +++ b/astroquery/eso/core.py @@ -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): @@ -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'): diff --git a/astroquery/ipac/irsa/ibe/core.py b/astroquery/ipac/irsa/ibe/core.py index 9f6a2fe881..3d46410cd7 100644 --- a/astroquery/ipac/irsa/ibe/core.py +++ b/astroquery/ipac/irsa/ibe/core.py @@ -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 @@ -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 ] @@ -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 diff --git a/astroquery/linelists/cdms/core.py b/astroquery/linelists/cdms/core.py index 67919d96ba..a5bb2d68fa 100644 --- a/astroquery/linelists/cdms/core.py +++ b/astroquery/linelists/cdms/core.py @@ -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 diff --git a/astroquery/simbad/get_votable_fields.py b/astroquery/simbad/get_votable_fields.py index be817969cd..4c597212c1 100644 --- a/astroquery/simbad/get_votable_fields.py +++ b/astroquery/simbad/get_votable_fields.py @@ -17,7 +17,7 @@ def reload_votable_fields_json(): # Find the first 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] diff --git a/astroquery/skyview/core.py b/astroquery/skyview/core.py index 5f1de6d6b1..c3a94b1293 100644 --- a/astroquery/skyview/core.py +++ b/astroquery/skyview/core.py @@ -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'] } diff --git a/astroquery/splatalogue/build_species_table.py b/astroquery/splatalogue/build_species_table.py index e0a11ed5b3..6fe0f787b2 100644 --- a/astroquery/splatalogue/build_species_table.py +++ b/astroquery/splatalogue/build_species_table.py @@ -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: diff --git a/astroquery/wfau/core.py b/astroquery/wfau/core.py index 7df464b142..fee25e5093 100644 --- a/astroquery/wfau/core.py +++ b/astroquery/wfau/core.py @@ -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):