0

I have soup with the following tag/information:

<table class="first_day info"> ==$0
<tbody>
 ...

I am trying to access this table but can't seem to get syntax right. I think it has to do with the ==$0 but I can't figure it out.

I'm using the following code/syntax:

briefs = briefs_meta.find("table",class_='first_day info')

and I've also tried:

briefs_meta = soup.find_all("table",{"class": "first_day info"})

But all I get is an empty result.

Insight?

Windstorm1981
  • 2,564
  • 7
  • 29
  • 57
  • Are you sure that it's not a dynamic table? Check HTML source code. Also note that your problem has nothing to do with [*==$0*](https://stackoverflow.com/questions/36999739/what-does-0-double-equals-dollar-zero-mean-in-chrome-developer-tools) – Andersson May 29 '18 at 15:15
  • How would I tell if it were a dynamic table? If it is does that cause problems? – Windstorm1981 May 29 '18 at 15:18
  • Try something like `assert "" in requests.get(URL).text`. In case of `AssertionError` - `table` is dynamic. It also might be a preventing of web scraping
    – Andersson May 29 '18 at 15:19
  • What is the URL you are trying to access? – Martin Evans May 29 '18 at 15:21
  • @Andersson I'm able to get information (including desired information if I use simple tag code: `brief_meta = soup.find_all("table")`. So I'm able to scrape. But it gives me tons more info than I want. Hence trying to cut down with use of `class` – Windstorm1981 May 29 '18 at 15:28
  • 1
    Try something like: `soup.select("table.first_day.info")` – Martin Evans May 29 '18 at 15:34

1 Answers1

1

When using BeautifulSoup to search multiple CSS classes, it is usually better to use a select(). For example:

for table in soup.select("table.first_day.info"):

This would then match:

<table class="info first_day">    

or:

<table class="first_day info">
Martin Evans
  • 45,791
  • 17
  • 81
  • 97