scraping with bs4
#
anti-trans legislation#
This section uses requests
and bs4
to scrape basic metadata about legislative bills that limit trans peopleâs rights in the USA. This dataset will be part of later lessons on âcleaning dataâ and âanalyzing dataâ, further on in this curriculum, where you will be working with the full text of the bills themselves.
what is bs4?
#
bs4 is short for BeautifulSoup4
, a python package for parsing HTML data. bs4âs power comes from using python syntax to access and manipulate HTML elements. This means that it uses the python language and its syntax to get information from pages written in the webâs main computer lanugage, HTML.
I explain what the code below does in âcommentsâ contained within each cell. Comments in Python are written on lines that begin with a hashtag #
. They are like annotations for the code. The #
which starts the comment line indicates to the computer that it should ignore that line (in other words, that the line is meant for human readers).
# import the following libraries for web scraping
import requests # to make https requests
from bs4 import BeautifulSoup # our web scraping library
import lxml # our parser (to handle html data)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 5
3 import requests # to make https requests
4 from bs4 import BeautifulSoup # our web scraping library
----> 5 import lxml # our parser (to handle html data)
ModuleNotFoundError: No module named 'lxml'
NOTE: If you get an error with importing one of the above libraries, make sure you have them installed. On Jupyter, that means running the following in your Command Line program (like Terminal or Gitbash):
pip install requests
pip install bs4
pip install lxml
On colab, run the same code, but within your python notebook. Be sure to put an exclamation before pip
, like:
!pip install requests
!pip install bs4
!pip install lxml
# save the data from the website as a "soup" object
site = requests.get('https://translegislation.com/bills/2025/US') # gets the URL
html_code = site.content # saves the HTML code
soup = BeautifulSoup(html_code) # creates a soup object
the soup
object#
This word âobjectâ in Python is something youâll hear often. It means a collection of data and functions that can work on that data. You can think of it as a way of representing real world objects (like this web page) that is organized and accessible, so you can search and manipulate that information with Python.
Letâs take an initial look into what this beautiful soup object allows us to do. It takes the HTML source, the specific HTML elements or âtags,â and makes it possible for us to access those tags using python syntax â specifically, the dot syntax to access information about elements (as a property
) and to do things (as a function
).
two ways of accessing html elements:#
1. selecting html elements using dot syntax#
Once we have created our soup
, we can use dot syntax to access html elements as a Python property
. Notice the result includes the entire html element (with opening and closing tags) that we are searching for.
# get title
soup.title
<title>United States Bills | Anti-trans legislation</title>
# checking for third level header element
soup.h3
<h3 class="chakra-heading css-1vygpf9"><style data-emotion="css f4h6uy">.css-f4h6uy{transition-property:var(--chakra-transition-property-common);transition-duration:var(--chakra-transition-duration-fast);transition-timing-function:var(--chakra-transition-easing-ease-out);cursor:pointer;-webkit-text-decoration:none;text-decoration:none;outline:2px solid transparent;outline-offset:2px;color:inherit;}.css-f4h6uy:hover,.css-f4h6uy[data-hover]{-webkit-text-decoration:underline;text-decoration:underline;}.css-f4h6uy:focus,.css-f4h6uy[data-focus]{box-shadow:var(--chakra-shadows-outline);}</style><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1">US<!-- --> <!-- -->HB1</a></h3>
# commented out, because output is too large!
# soup.div
Where is the div on the page? Go back to the inspector and see if you can find the first div.
2. selecting html elements using .find()
#
We can do the same as above, but using the find()
method.
soup.find('title')
<title>United States Bills | Anti-trans legislation</title>
soup.find('h3')
<h3 class="chakra-heading css-1vygpf9"><style data-emotion="css f4h6uy">.css-f4h6uy{transition-property:var(--chakra-transition-property-common);transition-duration:var(--chakra-transition-duration-fast);transition-timing-function:var(--chakra-transition-easing-ease-out);cursor:pointer;-webkit-text-decoration:none;text-decoration:none;outline:2px solid transparent;outline-offset:2px;color:inherit;}.css-f4h6uy:hover,.css-f4h6uy[data-hover]{-webkit-text-decoration:underline;text-decoration:underline;}.css-f4h6uy:focus,.css-f4h6uy[data-focus]{box-shadow:var(--chakra-shadows-outline);}</style><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1">US<!-- --> <!-- -->HB1</a></h3>
# commented out, because output is too large!
# soup.find('div')
narrowing down our data by text, class
, or href
#
getting just text
#
We can access the text within each tag, getting rid of tags like <p>
or <h3>
, by using the text
property.
soup.h3.text
'US HB1'
You can layer elements on top of each other to get more specific elements
soup.div.a.text
'Trans Legislation Tracker'
Using a variable, we can save just the text. This will be useful later, when we write more complex code, and migrate our data into a spreadsheet.
# saving the text from the level 3 header element to "bill_title"
bill_title = soup.h3.text
bill_title
'US HB1'
searching by HTML attributes: class
and href
#
HTML attributes contain additional inforamation about HTML tag. To access the attributes like class
, we use the syntax: tag['attr']
)For example, we can search for CSS classes using this syntax. (Read more about CSS classes).
# note that this prints the value of each attribute (like the name of the class), not
# the actual text contained within the larger element. For that, use the `text` property.
soup.h3['class']
['chakra-heading', 'css-1vygpf9']
A popular attribute is href
, which stands for hyperlink reference, and it contains the linkâs URL address.
link_location = soup.h3.a['href']
# the result will be just a `/` because it links to the current page
link_location
'/bills/2025/US/HB1'
Once we have a class
value, then we can get more granular about our searching. Here, we would use the find()
method. This is useful when there are a lot of objects with the same element, and you want more specificity.
For example, if we want to access a particular element that has a specific class name, include the class_=xxx
in your find()
or find_all()
call.
soup.find('h3', class_='css-1vygpf9')
<h3 class="chakra-heading css-1vygpf9"><style data-emotion="css f4h6uy">.css-f4h6uy{transition-property:var(--chakra-transition-property-common);transition-duration:var(--chakra-transition-duration-fast);transition-timing-function:var(--chakra-transition-easing-ease-out);cursor:pointer;-webkit-text-decoration:none;text-decoration:none;outline:2px solid transparent;outline-offset:2px;color:inherit;}.css-f4h6uy:hover,.css-f4h6uy[data-hover]{-webkit-text-decoration:underline;text-decoration:underline;}.css-f4h6uy:focus,.css-f4h6uy[data-focus]{box-shadow:var(--chakra-shadows-outline);}</style><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1015">US<!-- --> <!-- -->HB1015</a></h3>
soup.find_all('h3', class_='css-1vygpf9')
[<h3 class="chakra-heading css-1vygpf9"><style data-emotion="css f4h6uy">.css-f4h6uy{transition-property:var(--chakra-transition-property-common);transition-duration:var(--chakra-transition-duration-fast);transition-timing-function:var(--chakra-transition-easing-ease-out);cursor:pointer;-webkit-text-decoration:none;text-decoration:none;outline:2px solid transparent;outline-offset:2px;color:inherit;}.css-f4h6uy:hover,.css-f4h6uy[data-hover]{-webkit-text-decoration:underline;text-decoration:underline;}.css-f4h6uy:focus,.css-f4h6uy[data-focus]{box-shadow:var(--chakra-shadows-outline);}</style><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1">US<!-- --> <!-- -->HB1</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1015">US<!-- --> <!-- -->HB1015</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1016">US<!-- --> <!-- -->HB1016</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1017">US<!-- --> <!-- -->HB1017</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1028">US<!-- --> <!-- -->HB1028</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1139">US<!-- --> <!-- -->HB1139</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1208">US<!-- --> <!-- -->HB1208</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1282">US<!-- --> <!-- -->HB1282</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1866">US<!-- --> <!-- -->HB1866</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB2107">US<!-- --> <!-- -->HB2107</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB2197">US<!-- --> <!-- -->HB2197</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB2202">US<!-- --> <!-- -->HB2202</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB2378">US<!-- --> <!-- -->HB2378</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB2387">US<!-- --> <!-- -->HB2387</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB2616">US<!-- --> <!-- -->HB2616</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB2617">US<!-- --> <!-- -->HB2617</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB28">US<!-- --> <!-- -->HB28</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3205">US<!-- --> <!-- -->HB3205</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3247">US<!-- --> <!-- -->HB3247</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3406">US<!-- --> <!-- -->HB3406</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3492">US<!-- --> <!-- -->HB3492</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3518">US<!-- --> <!-- -->HB3518</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3688">US<!-- --> <!-- -->HB3688</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3765">US<!-- --> <!-- -->HB3765</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3792">US<!-- --> <!-- -->HB3792</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3802">US<!-- --> <!-- -->HB3802</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3917">US<!-- --> <!-- -->HB3917</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3944">US<!-- --> <!-- -->HB3944</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB3950">US<!-- --> <!-- -->HB3950</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4016">US<!-- --> <!-- -->HB4016</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4021">US<!-- --> <!-- -->HB4021</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4121">US<!-- --> <!-- -->HB4121</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4138">US<!-- --> <!-- -->HB4138</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4213">US<!-- --> <!-- -->HB4213</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4249">US<!-- --> <!-- -->HB4249</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4363">US<!-- --> <!-- -->HB4363</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4512">US<!-- --> <!-- -->HB4512</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4552">US<!-- --> <!-- -->HB4552</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4553">US<!-- --> <!-- -->HB4553</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB461">US<!-- --> <!-- -->HB461</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4618">US<!-- --> <!-- -->HB4618</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4730">US<!-- --> <!-- -->HB4730</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4754">US<!-- --> <!-- -->HB4754</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4779">US<!-- --> <!-- -->HB4779</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB4953">US<!-- --> <!-- -->HB4953</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB498">US<!-- --> <!-- -->HB498</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB5047">US<!-- --> <!-- -->HB5047</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB5050">US<!-- --> <!-- -->HB5050</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB5116">US<!-- --> <!-- -->HB5116</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB5166">US<!-- --> <!-- -->HB5166</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB5304">US<!-- --> <!-- -->HB5304</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB5342">US<!-- --> <!-- -->HB5342</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB600">US<!-- --> <!-- -->HB600</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB650">US<!-- --> <!-- -->HB650</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB653">US<!-- --> <!-- -->HB653</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB742">US<!-- --> <!-- -->HB742</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB800">US<!-- --> <!-- -->HB800</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB925">US<!-- --> <!-- -->HB925</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HR157">US<!-- --> <!-- -->HR157</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HR167">US<!-- --> <!-- -->HR167</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HR199">US<!-- --> <!-- -->HR199</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HR224">US<!-- --> <!-- -->HR224</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HR26">US<!-- --> <!-- -->HR26</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HR47">US<!-- --> <!-- -->HR47</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HR475">US<!-- --> <!-- -->HR475</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HR536">US<!-- --> <!-- -->HR536</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB1147">US<!-- --> <!-- -->SB1147</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB1551">US<!-- --> <!-- -->SB1551</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB1658">US<!-- --> <!-- -->SB1658</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB1811">US<!-- --> <!-- -->SB1811</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB1988">US<!-- --> <!-- -->SB1988</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB2008">US<!-- --> <!-- -->SB2008</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB2037">US<!-- --> <!-- -->SB2037</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB204">US<!-- --> <!-- -->SB204</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB209">US<!-- --> <!-- -->SB209</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB2091">US<!-- --> <!-- -->SB2091</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB2251">US<!-- --> <!-- -->SB2251</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB2296">US<!-- --> <!-- -->SB2296</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB2385">US<!-- --> <!-- -->SB2385</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB2702">US<!-- --> <!-- -->SB2702</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB312">US<!-- --> <!-- -->SB312</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB382">US<!-- --> <!-- -->SB382</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB405">US<!-- --> <!-- -->SB405</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB576">US<!-- --> <!-- -->SB576</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB591">US<!-- --> <!-- -->SB591</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB74">US<!-- --> <!-- -->SB74</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB851">US<!-- --> <!-- -->SB851</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB9">US<!-- --> <!-- -->SB9</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SB977">US<!-- --> <!-- -->SB977</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SR21">US<!-- --> <!-- -->SR21</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SR22">US<!-- --> <!-- -->SR22</a></h3>,
<h3 class="chakra-heading css-1vygpf9"><a class="chakra-link css-f4h6uy" href="/bills/2025/US/SR295">US<!-- --> <!-- -->SR295</a></h3>]
# save h3 element to a variable
bill_title = soup.find('h3', class_='css-1vygpf9')
bill_title
<h3 class="chakra-heading css-1vygpf9"><style data-emotion="css f4h6uy">.css-f4h6uy{transition-property:var(--chakra-transition-property-common);transition-duration:var(--chakra-transition-duration-fast);transition-timing-function:var(--chakra-transition-easing-ease-out);cursor:pointer;-webkit-text-decoration:none;text-decoration:none;outline:2px solid transparent;outline-offset:2px;color:inherit;}.css-f4h6uy:hover,.css-f4h6uy[data-hover]{-webkit-text-decoration:underline;text-decoration:underline;}.css-f4h6uy:focus,.css-f4h6uy[data-focus]{box-shadow:var(--chakra-shadows-outline);}</style><a class="chakra-link css-f4h6uy" href="/bills/2025/US/HB1">US<!-- --> <!-- -->HB1</a></h3>
Making variables is useful for layering other operations on top, like getting text
.
bill_title.text
'US HB1015'
looping through find_all()
to get just text#
Want to print out all tags of a specific element? Then we use find_all()
. Note: we use find_all()
rather than find()
, because only find_all()
returns a list like object, which is better for looping.
Letâs do this to get all of the bill names, with just the text.
soup.find_all('div', class_ ='css-4rck61').text
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[30], line 1
----> 1 soup.find_all('div', class_ ='css-4rck61').text
File ~/.conda/envs/jb/lib/python3.11/site-packages/bs4/element.py:2433, in ResultSet.__getattr__(self, key)
2431 def __getattr__(self, key):
2432 """Raise a helpful exception to explain a common code fix."""
-> 2433 raise AttributeError(
2434 "ResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?" % key
2435 )
AttributeError: ResultSet object has no attribute 'text'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
for i in soup.find_all('div', class_ ='css-4rck61'):
print(i.text)
US HB1HEALTHCAREPASSEDFEHB Protection Act of 2025To provide for reconciliation pursuant to title II of H. Con. Res. 14.PROHIBITING COVERAGE OF GENDER TRANSITION PROCEDURES AS AN ESSENTIAL HEALTH BENEFIT UNDER PLANS OFFERED BY EXCHANGES.â (1) [...] the Patient Protection and Affordable Care Act [...] is amended by adding at the end the following new subparagraph: (C) GENDER TRANSITION PROCEDURES.âFor plan years beginning on or after 25 January 1, 2027, the essential health benefits defined pursuant to paragraph (1) may not include items and services furnished for a gender transition procedure.View Bill
US HB1015HEALTHCAREINTRODUCEDPrison Rape Prevention Act of 2025To amend title 18, United States Code, to provide for certain rules for housing or transportation based on gender and to provide for a limitation on gender-related medical treatment.To amend title 18, United States Code, to provide for certain rules for housing or transportation based on gender and to provide for a limitation on gender-related medical treatment.View Bill
US HB1016BATHROOMINTRODUCEDProtecting Womenâs Private Spaces ActTo prohibit individuals from accessing or using single-sex facilities on Federal property other than those corresponding to their biological sex, and for other purposes.To prohibit individuals from accessing or using single-sex facilities on Federal property other than those corresponding to their biological sex, and for other purposes.View Bill
US HB1017BATHROOMINTRODUCEDStop the Invasion of Womenâs Spaces ActTo prohibit an entity from receiving Federal funds if such entity permits an individual to access or use a single-sex facility on the property of such entity that does not correspond to the biological sex of such person, and for other purposes.To prohibit an entity from receiving Federal funds if such entity permits an individual to access or use a single-sex facility on the property of such entity that does not correspond to the biological sex of such person, and for other purposes.View Bill
US HB1028SPORTSINTRODUCEDProtection of Women in Olympic and Amateur Sports ActTo modify eligibility requirements for amateur sports governing organizations.View Bill
US HB1139BIRTH CERTIFICATESINTRODUCEDPassport Sanity ActTo prohibit the Secretary of State from issuing a passport, passport card, or Consular Report of Birth Abroad that includes the unspecified (X) gender designation, and for other purposes.View Bill
US HB1208HEALTHCAREINTRODUCEDNo Tax Breaks for Radical Corporate Activism ActTo amend the Internal Revenue Code of 1986 to deny the trade or business expense deduction for the reimbursement of employee costs of child gender transition procedure or travel to obtain an abortion.Section 162 of the Internal Revenue Code of 1986 is amended [...] by inserting [...] the following new subsection: DISALLOWANCE OF CERTAIN EXPENSES RELATING TO ABORTION OR CHILD GENDER TRANSITION. [...] No deduction shall be allowed under this chapter to an employer for any amount paid or incurred to reimburse an employee for, or to otherwise pay, expenses in connection with (A) travel for the purpose of obtaining an abortion, or (B) any gender transition procedure for a minor child of the employee.View Bill
US HB1282EDUCATIONINTRODUCEDEliminate DEI in Colleges ActTo prohibit Federal funding for institutions of higher education that carry out diversity, equity, and inclusion initiatives, and for other purposes.View Bill
US HB1866CHILD ABUSEINTRODUCEDGUARD Act Guaranteeing Unalienable and Anatomical Rights for Dependents ActTo amend the Child Abuse Prevention and Treatment Act to disqualify any State that discriminates against parents or guardians who oppose medical, surgical, pharmacological, psychological treatment, or clothing and social changes related to affirming the subjective claims of gender identity expressed by any minor if such claimed identity is inconsistent with such minor's biological sex from receiving funding under such Act.View Bill
US HB2107HEALTHCAREINTRODUCEDChildrenâs Hospital GME Support Reauthorization Act of 2025To amend title III of the Public Health Service Act to reauthorize the program of payments to children's hospitals that operate graduate medical education programs, and for other purposes.View Bill
US HB2197HEALTHCAREINTRODUCEDNo 340B Savings for Transgender Care ActTo prevent 340B covered entities from using savings derived for sex reassignment surgeries, hormonal therapies, and for other purposes.View Bill
US HB2202HEALTHCAREINTRODUCEDEnd Taxpayer Funding of Gender Experimentation Act of 2025To prohibit taxpayer-funded gender transition procedures, and for other purposes.View Bill
US HB2378OTHERINTRODUCEDDefining Male and Female Act of 2025To establish clear and consistent biological definitions of male and female.In determining the meaning of any Act of Congress, or of any ruling, regulation, or interpretation of the various departments and Federal agencies of the United States, the termâ ââ(1) âboyâ means a minor human male; ââ(2) âfatherâ means a male parent; ââ(3) âfemaleâ, when used to refer to a natural person, means a person belonging, at conception, to the sex characterized by a reproductive system with the biological function of producing eggs (ova); ââ(4) âgender identityâ means an identity that reflects an internal and subjective sense of self, disconnected from biological reality and sex and existing on an indeterminate continuum, and, because such an identity does not provide a meaningful basis for identification for purposes of Federal law, the term shall not be recognized by the Federal Government as a replacement for sex; ââ(5) âgirlâ means a minor human female; ââ(6) âmaleâ, when used to refer to a natural person, means a person belonging, at conception, to the biological sex characterized by a reproductive system with the biological function of producing sperm; ââ(7) âmanâ, except when used as a generic reference to human beings, means an adult human male; ââ(8) âmotherâ means a female parent; ââ(9) âsexâ, when referring to a natural personâs individualâs sex, means the personâs immutable biological classification as either male or female, as bio8 logically determined and defined by this section; and ââ(10) âwomanâ means an adult human female.ââView Bill
US HB2387HEALTHCAREINTRODUCEDNo Harm ActTo prohibit Federal funds from being used for sex-trait altering treatments for minors, and for other purposes.No Federal funds may be made available for purposes of paying for, sponsoring, promoting, assisting, or supporting the furnishing of a sex-trait altering treatment to a minor.View Bill
US HB2616EDUCATIONINTRODUCEDPROTECT Kids Act Parental Rights Over The Education and Care of Their Kids ActTo require public elementary and middle schools that receive funds under the Elementary and Secondary Education Act of 1965 to obtain parental consent before changing a minor's gender markers, pronouns, or preferred name on any school form or sex-based accommodations, including locker rooms or bathrooms.To require public elementary and middle schools that receive funds under the Elementary and Secondary Education Act of 1965 to obtain parental consent before changing a minorâ gender markers, pronouns, or preferred name on any school form or sex-based accommodations, including locker rooms or bathrooms.View Bill
US HB2617EDUCATIONINTRODUCEDSay No to Indoctrination ActTo amend the Elementary and Secondary Education Act of 1965 to prevent the use of funds under such Act to teach or advance concepts related to gender ideology, and for other purposes.To amend the Elementary and Secondary Education Act of 1965 to prevent the use of funds under such Act to teach or advance concepts related to gender ideology, and for other purposes.View Bill
US HB28SPORTSENGROSSEDProtection of Women and Girls in Sports Act of 2025To amend the Education Amendments of 1972 to provide that for purposes of determining compliance with title IX of such Act in athletics, sex shall be recognized based solely on a person's reproductive biology and genetics at birth.It shall be a violation of subsection (a) for a recipient of Federal financial assistance who operates, sponsors, or facilitates athletic programs or activities to permit a person whose sex is male to participate in an athletic program or activity that is designated for women or girls.View Bill
US HB3205HEALTHCAREINTRODUCEDNo Subsidies for Gender Transition Procedures ActTo deny tax deductions and other Federal funding for the costs of gender transition procedures.View Bill
US HB3247ADOPTIONINTRODUCEDSAFE Home Act Sensible Adoption For Every Home ActTo prohibit entities receiving Federal assistance that are involved in adoption or foster care placements from delaying or denying placements under certain conditions.(A) prohibits any entity that receives Federal assistance and is involved in adoption or foster care placements from delaying or denying the placement of a minor child for adoption or into foster care, or otherwise discriminating in making a placement decision with a prospective or actual adoptive or foster parent, for any of the following reasons: (i) The parent raises, cares for, and addresses a child in a manner consistent with the childâs sex. (ii) The parent declines to consent to a child receiving any medical, surgical, pharmacological, or psychological treatment or other medical or mental health service for the purpose of attempting to alter the appearance of, or to validate a childâs perception of, the childâs sex, if the appearance or perception is inconsistent with the childâs sex. (iii) The parent declines to consent to an amendment or alteration to a childâs birth certificate, passport, driverâs license, school records, or other government-issued identification document, if the amendment or alteration is inconsistent with the childâs sex;View Bill
US HB3406MILITARYINTRODUCEDReadiness Over Wokeness ActTo prohibit individuals with gender dysphoria from serving as members of the Armed Forces, and for other purposes.View Bill
US HB3492HEALTHCAREINTRODUCEDProtect Childrenâs Innocence Act of 2025To amend section 116 of title 18, United States Code, with respect to genital and bodily mutilation and chemical castration of minors.View Bill
US HB3518EDUCATIONINTRODUCEDTo amend the Higher Education Act of 1965 to prohibit graduate medical schools from receiving Federal financial assistance if such schools adopt certain policies and requirements relating to diversity, equity, and inclusion.No graduate medical school at an institution of higher education shall be eligible to receive funds or any other form of financial assistance under any Federal program, including participation in any federally funded or guaranteed student loan program, unless the institution submits the following certifications to the Secretary: ââ(1) A certification that the institution does not, and will not, do any of the following: [...] ââ(D) Establish, maintain, or contract with a diversity, equity, and inclusion office, or any other functional equivalent of such an office, to serve the medical school. ââ(E) Require or incentivize an individual to complete a diversity statement professing or adhering to diversity, equity, and inclusion as a condition of, or benefit in, admission or employment at such school.View Bill
US HB3688HEALTHCAREINTRODUCEDProtecting Children from Experimentation Act of 2025To amend chapter 110 of title 18, United States Code, to prohibit gender transition procedures on minors, and for other purposes.View Bill
US HB3765MILITARYINTRODUCEDFALCONS Act Focusing Academies on Leadership and Cultivating Officers for National Security ActTo prohibit Federal service academies from providing training and education based on critical race theory or diversity, equity, and inclusion.No Federal funds may be obligated or expended to establish a curriculum, or to provide training or education based on critical race theory, diversity, equity, and inclusion at any of the following institutions: (1) The United States Military Academy. (2) The United States Naval Academy. (3) The United States Air Force Academy. (4) The United States Coast Guard Academy. (5) The United States Merchant Marine Academy.View Bill
US HB3792HEALTHCAREINTRODUCEDKIDS Act Kids Information Data Security ActTo amend title XI of the Social Security Act to prohibit providers participating in the Medicare program and State health care programs from requesting on intake forms information regarding the gender identity or sexual preference of minors.PROHIBITING PROVIDERS PARTICIPATING IN MEDICARE, MEDICAID, AND CHIP FROM REQUESTING ON INTAKE FORMS INFORMATION REGARDING THE GENDER IDENTITY OR SEXUAL PREFERENCE OF MINORS.View Bill
US HB3802EDUCATIONINTRODUCEDEO 14190 Act of 2025To codify Executive Order 14190 (relating to ending radical indoctrination in K-12 schooling).Executive Order 14190 (90 Fed. Reg. 8853; Ending Radical Indoctrination in Kâ12 Schooling) shall have the force and effect of law.View Bill
US HB3917SPORTSINTRODUCEDTo prohibit the participation of males in athletic programs or activities at the military service academies that are designated for women or girls.View Bill
US HB3944HEALTHCAREENGROSSEDLegislative Branch Appropriations Act, 2026 Military Construction, Veterans Affairs, and Related Agencies Appropriations Act, 2026 Agriculture, Rural Development, Food and Drug Administration, and Related Agencies Appropriations Act, 2026Making appropriations for military construction, the Department of Veterans Affairs, and related agencies for the fiscal year ending September 30, 2026, and for other purposes.None of the funds made available by this Act may be used for surgical procedures or hormone therapies for the purposes of gender affirming care.View Bill
US HB3950HEALTHCAREINTRODUCEDTo defend women's rights and protect freedom of conscience by using clear and accurate language and policies recognizing that women are biologically female and men are biologically male, and for other purposes.View Bill
US HB4016HEALTHCAREENGROSSEDDepartment of Defense Appropriations Act, 2026Making appropriations for the Department of Defense for the fiscal year ending September 30, 2026, and for other purposes.SEC. 8138. None of the funds appropriated or other wise made available by this Act may be used, with regards to a member of the Armed Forces with a minor dependent child enrolled in an Exceptional Family Member Program (EFMP)â (1) to provide gender transition procedures, including surgery or medication, to such child through such EFMP; (2) to provide a referral for a procedure described in paragraph (1) to such child through such EFMP; or (3) to approve a change of duty station for such member through such EFMP for the purpose of providing such child with access to procedures described in paragraph (1).View Bill
US HB4021OTHERINTRODUCEDPatriotism Not Pride ActTo prohibit certain Federal activity with respect to the promotion of Lesbian, Gay, Bisexual, Transgender, Queer, and Intersex Pride Month and the display of flags representing sexual orientation or gender identity on Federal property or grounds, and for other purposes.View Bill
US HB4121OTHERINTRODUCEDAgriculture, Rural Development, Food and Drug Administration, and Related Agencies Appropriations Act, 2026Making appropriations for Agriculture, Rural Development, Food and Drug Administration, and Related Agencies programs for the fiscal year ending September 30, 2026, and for other purposes.None of the funds made available by this Act may be used by the Secretary of Agriculture, the Com15 missioner of Food and Drugs, the Chairman of the Commodity Futures Trading Commission, or the Chairman of the Farm Credit Administration to fly or display a flag over a facility of the Department of Agriculture, the Food and Drug Administration, the Commodity Futures Trad20 ing Commission, or the Farm Credit Administration other than the flag of the United States; the flag of a State, territory, the District of Columbia; the flag of an Indian Tribal Government; the official flag of a U.S. Department or agency; or the Prisoners of War/Missing in Action flag.View Bill
US HB4138OTHERINTRODUCEDRestoring Biological Truth in Government ActTo prohibit the heads of executive agencies from asking about gender identity on any form or survey, to require executive agencies provide male and female as the only options to respond to questions about sex or gender on any forms or surveys and for other purposes.View Bill
US HB4213HEALTHCAREINTRODUCEDDepartment of Homeland Security Appropriations Act, 2026Making appropriations for the Department of Homeland Security for the fiscal year ending September 30, 2026, and for other purposes.SEC. 223. None of the funds appropriated or otherwise made available by this Act may be made available to administer hormone therapy medication or perform or facilitate any surgery for any person in custody of U.S. Immigration and Customs Enforcement for the purpose of gender-affirming care.View Bill
US HB4249MARRIAGEINTRODUCEDLegislative Branch Appropriations Act, 2026Making appropriations for the Legislative Branch for the fiscal year ending September 30, 2026, and for other purposes.SEC. 211. None of the funds made available by this Act may be used for any office, program, or activity for the purposes of diversity, equity, and inclusion training or implementation that promotes or perpetuates divisive concepts related to race or sex.View Bill
US HB4363SPORTSINTRODUCEDDefend Girls Athletics ActTo require elementary schools, secondary schools, and institutions of higher education to ensure biological fairness in women's sports as a condition of receiving Federal funds, and for other purposes.As a condition of receiving funds under this Act, a local educational agency shall ensure that each school under the jurisdiction of such agency complies with the requirements of Executive Order 14201 (90 Fed. Reg 9279; relating to keeping men out of womenâs sports).View Bill
US HB4512OTHERINTRODUCEDTRANS MICE Act Transgender Research on Animals Now Stops and Money for Ideological Cruelty Eliminated ActTo prohibit the availability of Federal funds for certain animal research, and for other purposes.(a) IN GENERAL.âNotwithstanding any other provision of law, no Federal funds may be made available to conduct, support, or fund (directly or indirectly) any covered research on a qualified animal. (1) COVERED RESEARCH.âThe term "covered research" means any research to study the effects of drugs, hormones, surgery, or other interventions to alter the body of a qualified animal to no longer correspond to the biological sex of such animal, including byâ (A) disrupting the development of an animalâs body; (B) inhibiting the natural functions of the animalâs body; or (C) modifying the physical appearance of an animalView Bill
US HB4552OTHERINTRODUCEDDepartment of Transportation Appropriations Act, 2026 Department of Housing and Urban Development Appropriations Act, 2026Making appropriations for the Departments of Transportation, and Housing and Urban Development, and related agencies for the fiscal year ending September 30, 2026, and for other purposes.SEC. 425. No funds made available by this Act shall be used in contravention ofâ [...] (b) Executive Order 14168 ["Defending Women from Gender Ideology Extremism and Restoring Biological Truth to the Federal Government"], or any substantially similar rule or order; [...] (e) Executive Order 14173 ["Ending Illegal Discrimination and Restoring Merit-Based Opportunity"], or any substantially similar rule or order;View Bill
US HB4553OTHERENGROSSEDEnergy and Water Development and Related Agencies Appropriations Act, 2026 Energy and Water Development and Related Agencies Appropriations Act, 2026Making appropriations for energy and water development and related agencies for the fiscal year ending September 30, 2026, and for other purposes.SEC. 508. None of the funds appropriated or other4 wise made available by this Act may be used to fly or display a flag over or within a facility of the federal government other than the flag of the United States, flag bearing an official U.S. Government seal or insignia, or POW/MIA flag.View Bill
US HB461MILITARYINTRODUCEDEliminate DEI in the Military ActTo prohibit the use of Federal funds for any DEI activity in the Armed Forces, and for other purposes.No Federal funds may be obligated or expended for any DEI activity ofâ (1) an Armed Force; (2) a national service academy; or (3) the Department of Defense. [...] "DEI activity" includes, with respect to diversity, equity, and inclusionâ (A) a training; (B) a program; (C) educational material; (D) a position of employment; and (E) an appointment.View Bill
US HB4618HEALTHCAREINTRODUCEDJamie Reed Protecting Our Kids from Child Abuse ActTo establish a Federal tort against pediatric gender clinics and other entities pushing gender-transition procedures that cause bodily injury to children or harm the mental health of children.View Bill
US HB4730EDUCATIONINTRODUCEDRestoring Truth and Sanity to American History ActTo codify Executive Order 14253 relating to restoring truth and sanity to American history, and for other purposes.The Vice President and the Director of the Office of Management and Budget shall work with Congress to en21 sure that future appropriations to the Smithsonian Institutionâ [...] (B) celebrate the achievements of women in the American Womenâs History Museum and do not recognize men as women in any respect, including byâ (i) promoting, celebrating, or favor abdepicting biological males competing in womenâs sports, winning awards designated for women, dressing as women, or entering private facilities designated for women; (ii) promoting, celebrating, or favorably depicting gender-affirming medicine, especially for minors; or (iii) including any other material that degrades the biological nature of sex or violates Federal civil rights laws.View Bill
US HB4754MARRIAGEINTRODUCEDDepartment of the Interior, Environment, and Related Agencies Appropriations Act, 2026Making appropriations for the Department of the Interior, environment, and related agencies for the fiscal year ending September 30, 2026, and for other purposes.SEC. 442. (a) In general.âNotwithstanding section 7 of title 1, United States Code, section 1738C of title 28, United States Code, or any other provision of law, none of the funds provided by this Act, or previous appropriations Acts, shall be used in whole or in part to take any discriminatory action against a person, wholly or partially, on the basis that such person speaks, or acts, in accordance with a sincerely held religious belief, or moral conviction, that marriage is, or should be recognized as, a union of one man and one woman.View Bill
US HB4779HEALTHCAREINTRODUCEDNational Security, Department of State, and Related Programs Appropriations Act, 2026Making appropriations for National Security, Department of State, and Related Programs for the fiscal year ending September 30, 2026, and for other purposes.None of the funds made available by this Act [...] may be made available in contravention of Executive Order 14187, relating to Protecting Children From Chemical and Surgical Mutilation, or shall be used or transferred to another Federal agency, board, or commission to fund [...] or any other program, organization, or association coordinated or operated by such non-governmental organization that either offers counseling regarding sex change surgeries, promotes sex change surgeries for any reason as an option, conducts or subsidizes sex change surgeries, promotes the use of medications or other substances to halt the onset of puberty or sexual development of minors, or otherwise promotes transgenderism.View Bill
US HB4953HEALTHCAREINTRODUCEDGender-Affirming Child Abuse Prevention ActTo authorize a civil right of action for individuals on whom gender-related medical treatment was performed while such individual was a minor, and for other purposes.View Bill
US HB498HEALTHCAREINTRODUCEDDo No Harm in Medicaid ActTo amend title XIX of the Social Security Act to prohibit Federal Medicaid funding for gender transition procedures for minors.View Bill
US HB5047EDUCATIONINTRODUCEDNo Woke Indoctrination of Military Kids ActTo prohibit activities that promote critical race theory and diversity, equity, and inclusion at schools operated by the Department of Defense Education Activity, and for other purposes.The Director of the Department of Defense Education Activity may notâ (1) maintain an office relating to diversity, equity, inclusion, or accessibility, or any substantially similar office; (2) maintain or employ a chief diversity officer or a substantially similar officer; (3) develop, implement, distribute, or publishâ (A) plans, strategic plans, reports, or surveys relating to diversity, equity, inclusion, or accessibility; or (B) action plans, reports, or surveys relating to equity or substantially similar plans, reports, or surveys; (4) develop, implement, or maintain a resource group or an affinity group based on race, color, ethnicity, national origin, sexual orientation, or gender identity;View Bill
US HB5050EDUCATIONINTRODUCEDSafety and Opportunity for Girls Act of 2025To clarify protections related to sex and sex-segregated spaces and to activities under title IX of the Education Amendments of 1972.(1) to prohibit, to authorize the Secretary to prohibit, or to authorize the Secretary to make receipt of funding under this title contingent upon an educational institution forgoing the maintenance of sex-segregated spaces by educational institutions, including bathrooms and locker rooms; orView Bill
US HB5116EDUCATIONINTRODUCEDEmpower Parents to Protect their Kids ActTo require elementary schools and secondary schools that receive Federal funds to obtain parental consent before facilitating a child's gender transition in any form, and for other purposes.View Bill
US HB5166HEALTHCAREINTRODUCEDJudiciary Appropriations Act, 2026 District of Columbia Appropriations Act, 2026 Executive Office of the President Appropriations Act, 2026 Department of the Treasury Appropriations Act, 2026Making appropriations for financial services and general government for the fiscal year ending September 30, 2026, and for other purposes.SEC. 761. None of the funds made available by this Act, or in any previous appropriation, may be provided for in insurance plans in the Federal Employees Health Benefits program to cover the cost of surgical procedures or puberty blockers or hormone therapy for the purpose of gender affirming care.View Bill
US HB5304HEALTHCAREINTRODUCEDDepartments of Labor, Health and Human Services, and Education, and Related Agencies Appropriations Act, 2026 Department of Labor Appropriations Act, 2026Making appropriations for the Departments of Labor, Health and Human Services, and Education, and related agencies for the fiscal year ending September 30, 2026, and for other purposes.SEC. 244. None of the funds made available by this Act may be used for any social, psychological, behavioral, or medical intervention performed for the purposes of intentionally changing the body of an individual (including by disrupting the bodyâs development, inhibiting its natural functions, or modifying its appearance) to no longer correspond to the individualâs biological sex.View Bill
US HB5342OTHERINTRODUCEDScience Appropriations Act, 2026 Commerce, Justice, Science, and Related Agencies Appropriations Act, 2026 Department of Justice Appropriations Act, 2026 Department of Commerce Appropriations Act, 2026Making appropriations for the Departments of Commerce and Justice, Science, and Related Agencies for the fiscal year ending September 30, 2026, and for other purposes.SEC. 561. None of the funds made available by this or any other Act may be used to investigate, litigate, or advocate against any person or recipient, as currently defined at section 106.2 of title 34, Code of Federal Regulations, for defining "sex" [...] to mean biological sex, male or female, as determined by the type of gamete an individual produces; and for defining "boys and girls" to mean only biological boys, whose DNA consists of one X sex chromosome and one Y sex chromosome, and biological girls, whose DNA consists of two X sex chromosomes.View Bill
US HB600HEALTHCAREINTRODUCEDWHO is Accountable ActTo prohibit the use of funds to seek membership in the World Health Organization or to provide assessed or voluntary contributions to the World Health Organization.No funds available to any Federal department or agency may be used to seek membership by the United States in the World Health Organization or to provide assessed or voluntary contributions to the World Health Organization until such time as the Secretary of State certifies to Congress that the World Health Organization meets the conditions described in subsection (b): [...] (7) The World Health Organization has ceased all funding for, engagement in, and messaging with respect to certain controversial and politically charged issues that are non-germane to the World Health Organizationâs directive, includingâ (A) so-called "gender identity" and harmful rhetoric relating to "gender affirming care";View Bill
US HB650PARENTAL RIGHTSINTRODUCEDFamiliesâ Rights and Responsibilities ActTo protect the right of parents to direct the upbringing of their children as a fundamental right.The protections of the fundamental right of parents to direct the upbringing, education, and health care of their children afforded by this Act are in addition to the protections provided under Federal law, State law, and the State and Federal constitutions. [...] Government shall not substantially burden the fundamental right of parents to direct the upbringing, education, and health care of their children without demonstrating that the infringement is required by a compelling governmental interest of the highest order as applied to the parent and the child and is the least restrictive means of furthering that compelling governmental interest.View Bill
US HB653HEALTHCAREINTRODUCEDProtect Minors from Medical Malpractice Act of 2025To protect children from medical malpractice in the form of gender transition procedures.A medical practitioner [...] who performs a gender-transition procedure on an individual who is less than 18 years of age shall [...] be liable to the individual if injured (including any physical, psychological, emotional, or physiological harms) by such procedure, related treatment, or the aftereffects of the procedure or treatment.View Bill
US HB742HEALTHCAREINTRODUCEDPROTECTS Act of 2025 Protecting Resources Of Taxpayers to Eliminate Childhood Transgender Surgeries Act of 2025To prohibit Federal funds from being used to provide certain gender transition procedures to minors.No Federal funds may be used or otherwise made available to provide or refer for a specified gender transition procedure to an individual under the age of 18 or to reimburse any entity for providing such a procedure to such an individual.View Bill
US HB800OTHERINTRODUCEDDEI to DIE ActTo enact into law the executive order relating to ending diversity, equity, and inclusion programs in the Federal Government, and for other purposes.To enact into law the executive order relating to ending diversity, equity, and inclusion programs in the Federal Government, and for other purposes.View Bill
US HB925OTHERINTRODUCEDDismantle DEI Act of 2025To ensure equal protection of the law, to prevent racism in the Federal Government, and for other purposes.Not later than 180 days after the date of enactment of this Act, the Director of the Office of Personnel Management shallâ [...] (3) terminate, close, and wind up the Office of Diversity, Equity, Inclusion, and Accessibility of the Office of Personnel Management (referred to in this paragraph as ââODEIAââ) and undertake an appropriate reduction in force with respect to, and not transfer, reassign, or redesignate any, employees or contractors of ODEIA, the positions or functions of whom are eliminated by operation of this Act or the amendments made by this Act; and (4) terminate, close, and wind up the Chief Diversity Officers Executive Council and undertake an appropriate reduction in force with respect to, and not transfer, reassign, or redesignate any, employees or contractors of that Council, the positions or functions of whom are eliminated by operation of this Act or the amendments made by this Act.View Bill
US HR157HEALTHCAREINTRODUCEDImpeaching John Deacon Bates, a judge of the United States District Court for the District of Columbia, for high crimes and misdemeanors.Resolved, That John Deacon Bates, a judge of the United States District Court for the District of Columbia, is impeached for high crimes and misdemeanors [...]: Judge Bates ordered the Centers for Disease Control and Prevention (CDC), the Department of Health and Human Services (HHS), and the Food and Drug Administration (FDA) to restore socially divisive and destructive LGBTQI+ content on taxpayer subsidized government webpages, in contravention of Executive Order 14168View Bill
US HR167OTHERINTRODUCEDTo establish uniform standards for flag displays in the House of Representatives facilities.The only flags that may be displayed are the following: (1) The United States flag, as defined in section 700(b) of title 18, United States Code. (2) The official House of Representatives flags and insignia. (3) The State flag of the represented district of a Member of the House of Representatives, dis17 played adjacent to the office of such Member. (4) A military service flag. (5) The POW/MIA flag. (6) Any flag eligible to be displayed in the Hall of Tribal Nations of the Bureau of Indian Affairs Museum Program. (7) The flags of visiting foreign dignitaries during an official visit.View Bill
US HR199OTHERINTRODUCEDCondemning woke foreign aid programs.View Bill
US HR224HEALTHCAREINTRODUCEDExpressing support for the recognition of "Detransition Awareness Day".The House of Representatives (1) supports the recognition of "Detransition Awareness Day" to acknowledge the experiences of individuals who [...] have returned to living in the reality of their sex.View Bill
US HR26OTHERINTRODUCEDDeeming certain conduct of members of Antifa as domestic terrorism and designating Antifa as a domestic terrorist organization.Deeming certain conduct of members of Antifa as domestic terrorism and designating Antifa as a domestic terrorist organization. [...] Whereas, in August 2022, Antifa ardently defended the sexualization of children by guarding a "kid-friendly" drag show at a North Texas distillery;View Bill
US HR47SPORTSINTRODUCEDConcerning the National Collegiate Athletic Association policy for eligibility in women's sports.The House of Representatives (1) calls on the National Collegiate Athletic Association (referred to in this resolution as "NCAA") to revoke its transgender student-athlete eligibility policy that directly discriminates against female student athletes;View Bill
US HR475OTHERINTRODUCEDSupporting the designation of Family Month.Whereas the month of June was first declared as Pride Month by President Bill Clinton in 1999 and has been done so by Presidents Barack Obama and Joe Biden, rejecting the importance of marriage and family; Whereas Americans are inundated with perverse Pride Month displays and events throughout the month of June that denigrate the nuclear family; Whereas Americans who hold to a traditional view of marriage and family are often disparaged;View Bill
US HR536SPORTSINTRODUCEDSupporting the designation of the week including June 23, 2025, as "National Women's Sports Week" to celebrate the anniversary of the passage of title IX and the growth of women's sports.Whereas policies allowing for the inclusion of men in womenâs sports have no basis in biological fact or valid medical research;View Bill
US SB1147OTHERINTRODUCEDDefining Male and Female Act of 2025A bill to establish clear and consistent biological definitions of male and female.In determining the meaning of any Act of Congress, or of any ruling, regulation, or interpretation of the various departments and Federal agencies of the United States, the termâ ââ(1) âboyâ means a minor human male; ââ(2) âfatherâ means a male parent; ââ(3) âfemaleâ, when used to refer to a natural person, means a person belonging, at conception, to the sex characterized by a reproductive system with the biological function of producing eggs (ova); ââ(4) âgender identityâ means an identity that reflects an internal and subjective sense of self, disconnected from biological reality and sex and existing on an indeterminate continuum, and, because such an identity does not provide a meaningful basis for identification for purposes of Federal law, the term shall not be recognized by the Federal Government as a replacement for sex; ââ(5) âgirlâ means a minor human female; ââ(6) âmaleâ, when used to refer to a natural person, means a person belonging, at conception, to the biological sex characterized by a reproductive system with the biological function of producing sperm; ââ(7) âmanâ, except when used as a generic reference to human beings, means an adult human male; ââ(8) âmotherâ means a female parent; ââ(9) âsexâ, when referring to a natural personâs individualâs sex, means the personâs immutable biological classification as either male or female, as bio8 logically determined and defined by this section; and ââ(10) âwomanâ means an adult human female.ââView Bill
US SB1551HEALTHCAREINTRODUCEDNo Subsidies for Gender Transition Procedures ActA bill to deny tax deductions and other Federal funding for the costs of gender transition procedures.View Bill
US SB1658ADOPTIONINTRODUCEDSAFE Home Act Sensible Adoption For Every Home ActA bill to prohibit entities receiving Federal assistance that are involved in adoption or foster care placements from delaying or denying placements under certain conditions.(A) prohibits any entity that receives Federal assistance and is involved in adoption or foster care placements from delaying or denying the placement of a minor child for adoption or into foster care, or otherwise discriminating in making a placement decision with a prospective or actual adoptive or foster parent, for any of the following reasons: (i) The parent raises, cares for, and addresses a child in a manner consistent with the childâs sex. (ii) The parent declines to consent to a child receiving any medical, surgical, pharmacological, or psychological treatment or other medical or mental health service for the purpose of attempting to alter the appearance of, or to validate a childâs perception of, the childâs sex, if the appearance or perception is inconsistent with the childâs sex. (iii) The parent declines to consent to an amendment or alteration to a childâs birth certificate, passport, driverâs license, school records, or other government-issued identification document, if the amendment or alteration is inconsistent with the childâs sex;View Bill
US SB1811EDUCATIONINTRODUCEDEmbracing Anti-Discrimination, Unbiased Curricula, and Advancing Truth in Education ActA bill to amend the Higher Education Act of 1965 to prohibit graduate medical schools from receiving Federal financial assistance if such schools adopt certain policies and requirements relating to diversity, equity, and inclusion.No graduate medical school at an institution of higher education shall be eligible to receive funds or any other form of financial assistance under any Federal program, including participation in any federally funded or guaranteed student loan program, unless the institution submits the following certifications to the Secretary: ââ(1) A certification that the institution does not, and will not, do any of the following: [...] ââ(D) Establish, maintain, or contract with a diversity, equity, and inclusion office, or any other functional equivalent of such an office, to serve the medical school. ââ(E) Require or incentivize an individual to complete a diversity statement professing or adhering to diversity, equity, and inclusion as a condition of, or benefit in, admission or employment at such school.View Bill
US SB1988SPORTSINTRODUCEDA bill to prohibit the participation of males in athletic programs or activities at the military service academies that are designated for women or girls.PROHIBITION ON PARTICIPATION OF MALES IN ATHLETIC PROGRAMS OR ACTIVITIES AT THE MILITARY SERVICE ACADEMIES THAT ARE DESIGNATED FOR WOMEN OR GIRLS (a) IN GENERAL.âThe Secretary of Defense shall ensure that the United States Military Academy, the United States Naval Academy, and the United States Air Force Academy do not permit a person whose sex is male to participate in an athletic program or activity that is designated for women or girls.View Bill
US SB2008HEALTHCAREINTRODUCEDStop Funding Genital Mutilation ActA bill to amend title XIX of the Social Security Act to prohibit Medicaid and CHIP funding for gender transition procedures.View Bill
US SB2037OTHERINTRODUCEDRestoring Biological Truth to the Workplace ActA bill to amend title VII of the Civil Rights Act of 1964 to prohibit discrimination against employees on the basis of expression that describes, asserts, or reinforces the binary or biological nature of sex.discrimination,employmentView Bill
US SB204PARENTAL RIGHTSINTRODUCEDFamiliesâ Rights and Responsibilities ActA bill to protect the right of parents to direct the upbringing of their children as a fundamental right.Congress finds the following: [...] the natural right of parents to care for their children [...] (5) The right encompasses the authority of parents to direct the upbringing, education, and health care of their children according to the dictates of their conscience, to direct the upbringing, education, and health care of their children in their own beliefs and religion, and to be the primary decision maker for their child until the child reaches adulthood.View Bill
US SB209HEALTHCAREINTRODUCEDProtecting Minors from Medical Malpractice Act of 2025A bill to protect children from medical malpractice in the form of gender-transition procedures.A medical practitioner [...] who performs a gender-transition procedure on an individual who is less than 18 years of age shall [...] be liable to the individual if injured (including any physical, psychological, emotional, or physiological harms) by such procedure, related treatment, or the aftereffects of the procedure or treatment.View Bill
US SB2091PRONOUNSINTRODUCEDRestoring Lethality ActA bill to eliminate statutory provisions relating to diversity, equity, and inclusion in the Department of Defense.A bill to eliminate statutory provisions relating to diversity, equity, and inclusion in the Department of Defense. [...] (e) IDENTIFICATION OF GENDER OR PERSONAL PRONOUNS IN OFFICIAL CORRESPONDENCE.âSection 986 of title 10, United States Code, is repealed.View Bill
US SB2251EDUCATIONINTRODUCEDSay No to Indoctrination ActA bill to amend the Elementary and Secondary Education Act of 1965 to prevent the use of funds under such Act to teach or advance concepts related to gender ideology, and for other purposes.View Bill
US SB2296HEALTHCAREINTRODUCEDAtomic Energy Testing Liability Act Military Construction Authorization Act for Fiscal Year 2026An original bill to authorize appropriations for fiscal year 2026 for military activities of the Department of Defense, for military construction, and for defense activities of the Department of Energy, to prescribe military personnel strengths for such fiscal year, and for other purposes.SEC. 706. RESTRICTION ON PERFORMANCE OF SEX CHANGE SURGERIES. (a) IN GENERAL.â Chapter 55 of title 10, United States Code, is amended by inserting after section 1093 the following new section: ââ§ 1093a. Performance of sex change surgeries: restrictions (a) RESTRICTION ON USE OF FUNDS.âFunds available to the Department of Defense may not be used to perform or facilitate sex change surgeries. (b) RESTRICTION ON USE OF FACILITIES.âNo military medical treatment facility or other facility of the Department of Defense may be used to perform or facilitate a sex change surgery.ââView Bill
US SB2385EDUCATIONINTRODUCEDRestoring Truth and Sanity to American History ActA bill to codify Executive Order 14253 relating to restoring truth and sanity to American history, and for other purposes.The Vice President and the Director of the Office of Management and Budget shall work with Congress to ensure that future appropriations to the Smithsonian Institutionâ [...] (B) celebrate the achievements of women in the American Womenâs History Museum and do not recognize men as women in any respect, including byâ (i) promoting, celebrating, or favor abdepicting biological males competing in womenâs sports, winning awards designated for women, dressing as women, or entering private facilities designated for women; (ii) promoting, celebrating, or favorably depicting gender-affirming medicine, especially for minors; or (iii) including any other material that degrades the biological nature of sex or violates Federal civil rights laws.View Bill
US SB2702EDUCATIONINTRODUCEDEmpower Parents to Protect their Kids Act of 2025A bill to require local educational agencies, State educational agencies, and other governmental education entities to respect the rights of parents regarding gender transition, and for other purposes.No Federal funds shall be made available to any elementary school or secondary school unless the elementary school or secondary school, with respect to students enrolled at the school who have not yet reached 18 years of age, complies with each of the following requirements: (1) School employees do not proceed with any accommodation intended to affirm a studentâs purported "identity" that is incongruent with the studentâs sex, or any action to facilitate or otherwise aid and abet a minor in adopting such an identity, including referral or recommendation to any third party medical provider for a gender transition procedure, unless the employees have received express pa19 rental consent to do so. (2) School employees do not facilitate, encourage, or coerce students to withhold information from their parents regarding the studentâs purported identity when it is incongruent with the studentâs sex. (3) School employees do not withhold or hide information from parents about a studentâs discomfort with their sex, their desire for an identity that is incongruent with their sex, their profession of an identity that is incongruent with their sex, or their desire to undergo a gender transition procedure. (4) School employees do not encourage, pressure, or coerce the parents of students, or students themselves, to proceed with any intervention to affirm the studentâs adoption of an identity that is in11 congruent with their sex.View Bill
US SB312HEALTHCAREINTRODUCEDJamie Reed Protecting Our Kids from Child Abuse ActA bill to establish a Federal tort against pediatric gender clinics and other entities pushing gender-transition procedures that cause bodily injury to children or harm the mental health of children.The following individuals and entities shall be liable in accordance with this section to any individual who suffers bodily injury or harm to mental health (including any physical, psychological, emotional, or physiological harm) that is attributable, in whole or in part, to a gender-transition procedure performed on the individual when the individual was a minor: (1) A pediatric gender clinic where the gender transition procedure was provided. (2) Any medical practitioner who administered health care, at the time of the particular procedure, at the pediatric gender clinic where the gender-transition procedure was provided. (3) An institution of higher education that hosts, operates, partners with, provides funding to, or is otherwise affiliated with the pediatric gender clinic where the gender-transition procedure was provided. (4) A hospital that hosts, operates, partners with, provides funding to, or is otherwise affiliated with the pediatric gender clinic where the gender6 transition procedure was provided. (5) Any medical practitioner who performed the gender-transition procedure on the individual.View Bill
US SB382OTHERINTRODUCEDDismantle DEI Act of 2025A bill to ensure equal protection of the law, to prevent racism in the Federal Government, and for other purposes.View Bill
US SB405SPORTSINTRODUCEDProtection of Women in Olympic and Amateur Sports ActA bill to modify eligibility requirements for amateur sports governing organizations.Adding [...] the following: "(20) prohibits a person whose sex is male from participating in an amateur athletic competition that is designated for females, women, or girls."View Bill
US SB576OTHERINTRODUCEDOne Flag for All ActA bill to prohibit the flying, draping, or other display of any flag other than the flag of the United States at covered public buildings, and for other purposes.No flag that is not the flag of the United States may be flown, draped, or otherwise displayedâ (1) on the exterior of a covered public building; or (2) in an area of a covered public building that is fully accessible to the public, including an entryway or hallway.View Bill
US SB591EMPLOYMENTINTRODUCEDRestore Merit to Government Service Act of 2025A bill to reform the Federal hiring process, to restore merit to Government service, and for other purposes.Congress finds the following: [...] (3) Appointments in the Federal Government should not be focused on impermissible factors, such as a commitment toâ (A) illegal racial discrimination under the guise of "equity"; or (B) the invented concept of "gender identity" over sex.View Bill
US SB74SPORTSINTRODUCEDFair Play for Girls ActA bill to require the Attorney General to submit to Congress a report relating to violence against women in athletics.View Bill
US SB851CHILD ABUSEINTRODUCEDGUARD Act Guaranteeing Unalienable and Anatomical Rights for Dependents ActA bill to amend the Child Abuse Prevention and Treatment Act to disqualify any State that discriminates against parents or guardians who oppose medical, surgical, pharmacological, psychological treatment, or clothing and social changes related to affirming the subjective claims of gender identity expressed by any minor if such claimed identity is inconsistent with such minor's biological sex from receiving funding under such Act.View Bill
US SB9SPORTSINTRODUCEDProtection of Women and Girls in Sports Act of 2025A bill to provide that for purposes of determining compliance with title IX of the Education Amendments of 1972 in athletics, sex shall be recognized based solely on a person's reproductive biology and genetics at birth.To provide that for purposes of determining compliance with title IX of the Education Amendments of 1972 in athletics, sex shall be recognized based solely on a personâs reproductive biology and genetics at birth.View Bill
US SB977HEALTHCAREINTRODUCEDEnd Taxpayer Funding of Gender Experimentation Act of 2025A bill to prohibit taxpayer-funded gender transition procedures, and for other purposes.View Bill
US SR21SPORTSINTRODUCEDA resolution designating October 10, 2025, as "American Girls in Sports Day".Whereas the National Association of Intercollegiate Athletics (NAIA) has instituted new policies to protect biological girls in sports and ensure that only student athletes whose biological sex is female will be allowed to compete in NAIA-sponsored women's sports teams; Whereas it is imperative that women's and girl's opportunities to compete athletically are protected; and Whereas October 10th, as represented by the Roman numerals "XX", signifies the female XX chromosomes: Now, therefore, be it Resolved, That the Senateâ (1) recognizes October 10, 2025, as "American Girls in Sports Day"; [...] (3) recognizes the importance of Title IX in protecting biological women in sports; and (4) calls on sports-governing bodies in the United States and abroad to protect biological women and girls in sports.View Bill
US SR22SPORTSINTRODUCEDA resolution concerning the National Collegiate Athletic Association policy for eligibility in women's sports.The House of Representatives (1) calls on the National Collegiate Athletic Association (referred to in this resolution as "NCAA") to revoke its transgender student-athlete eligibility policy that directly discriminates against female student athletes;View Bill
US SR295SPORTSINTRODUCEDA resolution supporting the designation of the week of June 23 through June 29, 2025, as "National Women's Sports Week" to celebrate the anniversary of the enactment of title IX of the Education Amendments of 1972 and the growth of women's sports.View Bill
methods vs attributes#
The decision to use dot syntax (like soup.h3.a
) or a method (like find()
or find_all()
) depends on what youâre trying to do, and what kind of data you have about the thing youâre trying to scrape. In many cases, you could use either one.
The difference between the two is how data is stored in Python. In dot syntax, itâs stored as an attribute, or property, of the soup object. By using a method like find()
, youâre executing a function to find the data.
individual challenge:#
Letâs try doing the same thing two different ways. What if I wanted to get the link, the value of the href
attribute, using both methods and attributes?
# use find to search by element and class. Now, grab the link.
link = soup.find('h3', class_='css-1vygpf9').a['href']
print(link)
/bills/2025/US/HB1015
# there are multiple ways to do this! If you don't need the class, just use dot syntax
soup.h3.a['href']
'/bills/2025/US/HB1015'
You can also use find()
to search an element by specific attribute. Just include the class_=xxx
in your find()
call.
for i in soup.find_all('h3'):
print(i.text)
US HB1
US HB1015
US HB1016
US HB1017
US HB1028
US HB1139
US HB1208
US HB1282
US HB1866
US HB2107
US HB2197
US HB2202
US HB2378
US HB2387
US HB2616
US HB2617
US HB28
US HB3205
US HB3247
US HB3406
US HB3492
US HB3518
US HB3688
US HB3765
US HB3792
US HB3802
US HB3917
US HB3944
US HB3950
US HB4016
US HB4021
US HB4121
US HB4138
US HB4213
US HB4249
US HB4363
US HB4512
US HB4552
US HB4553
US HB461
US HB4618
US HB4730
US HB4754
US HB4779
US HB4953
US HB498
US HB5047
US HB5050
US HB5116
US HB5166
US HB5304
US HB5342
US HB600
US HB650
US HB653
US HB742
US HB800
US HB925
US HR157
US HR167
US HR199
US HR224
US HR26
US HR47
US HR475
US HR536
US SB1147
US SB1551
US SB1658
US SB1811
US SB1988
US SB2008
US SB2037
US SB204
US SB209
US SB2091
US SB2251
US SB2296
US SB2385
US SB2702
US SB312
US SB382
US SB405
US SB576
US SB591
US SB74
US SB851
US SB9
US SB977
US SR21
US SR22
US SR295
getting data from each bill card#
For our project, we want to scrape information about each bill contained within the bill cards.
Like all good programmers, we will break our task up into a number of steps:
isolate the bill_cards data from the rest of the webpage
pick out the information we want from the bill cards
Each of these steps itself contains smaller steps, which we will figure out as we go along. Letâs begin with the first step. Here, we want to separate out that information (within the bill cards) from the rest of the website. This will make it easier to then go grab the elements we need later.
step 1: isolate our bill_cards data from the rest of the web page#
First, create a new object called bill_cards
, which enables us to narrow down the parts of the website that we want to scrape.
# to get the element and class for the cards, use the inspector
bill_cards = soup.find_all('div', class_ ='css-4rck61')
Letâs use a loop to check that we have all the right data. In the next section, we will be able to pick out specific pieces of text, based on their HTML markup.
# printing out all the text contained in the "bill cards" div
for i in bill_cards:
print(i.text)
US HB1015HEALTHCAREINTRODUCEDTo amend title 18, United States Code, to provide for certain rules for housing or transportation based on gender and to provide for a limitation on gender-related medical treatment.To amend title 18, United States Code, to provide for certain rules for housing or transportation based on gender and to provide for a limitation on gender-related medical treatment.View Bill
US HB1016BATHROOMINTRODUCEDTo prohibit individuals from accessing or using single-sex facilities on Federal property other than those corresponding to their biological sex, and for other purposes.To prohibit individuals from accessing or using single-sex facilities on Federal property other than those corresponding to their biological sex, and for other purposes.View Bill
US HB1017BATHROOMINTRODUCEDTo prohibit an entity from receiving Federal funds if such entity permits an individual to access or use a single-sex facility on the property of such entity that does not correspond to the biological sex of such person, and for other purposes.To prohibit an entity from receiving Federal funds if such entity permits an individual to access or use a single-sex facility on the property of such entity that does not correspond to the biological sex of such person, and for other purposes.View Bill
US HB1028SPORTSINTRODUCEDTo modify eligibility requirements for amateur sports governing organizations.View Bill
US HB1139BIRTH CERTIFICATESINTRODUCEDTo prohibit the Secretary of State from issuing a passport, passport card, or Consular Report of Birth Abroad that includes the unspecified (X) gender designation, and for other purposes.View Bill
US HB1282EDUCATIONINTRODUCEDTo prohibit Federal funding for institutions of higher education that carry out diversity, equity, and inclusion initiatives, and for other purposes.View Bill
US HB28SPORTSENGROSSEDProtection of Women and Girls in Sports Act of 2025To amend the Education Amendments of 1972 to provide that for purposes of determining compliance with title IX of such Act in athletics, sex shall be recognized based solely on a person's reproductive biology and genetics at birth.It shall be a violation of subsection (a) for a recipient of Federal financial assistance who operates, sponsors, or facilitates athletic programs or activities to permit a person whose sex is male to participate in an athletic program or activity that is designated for women or girls.View Bill
US HB461MILITARYINTRODUCEDEliminate DEI in the Military ActTo prohibit the use of Federal funds for any DEI activity in the Armed Forces, and for other purposes.View Bill
US HB498HEALTHCAREINTRODUCEDTo amend title XIX of the Social Security Act to prohibit Federal Medicaid funding for gender transition procedures for minors.View Bill
US HB600HEALTHCAREINTRODUCEDWHO is Accountable ActTo prohibit the use of funds to seek membership in the World Health Organization or to provide assessed or voluntary contributions to the World Health Organization.No funds available to any Federal department or agency may be used to seek membership by the United States in the World Health Organization or to provide assessed or voluntary contributions to the World Health Organization until such time as the Secretary of State certifies to Congress that the World Health Organization meets the conditions described in subsection (b): [...] (7) The World Health Organization has ceased all funding for, engagement in, and messaging with respect to certain controversial and politically charged issues that are non-germane to the World Health Organizationâs directive, includingâ (A) so-called "gender identity" and harmful rhetoric relating to "gender affirming care";View Bill
US HB653HEALTHCAREINTRODUCEDTo protect children from medical malpractice in the form of gender transition procedures.View Bill
US HB742HEALTHCAREINTRODUCEDTo prohibit Federal funds from being used to provide certain gender transition procedures to minors.View Bill
US HB800OTHERINTRODUCEDTo enact into law the executive order relating to ending diversity, equity, and inclusion programs in the Federal Government, and for other purposes.To enact into law the executive order relating to ending diversity, equity, and inclusion programs in the Federal Government, and for other purposes.View Bill
US HR26OTHERINTRODUCEDDeeming certain conduct of members of Antifa as domestic terrorism and designating Antifa as a domestic terrorist organization.Deeming certain conduct of members of Antifa as domestic terrorism and designating Antifa as a domestic terrorist organization. [...] Whereas, in August 2022, Antifa ardently defended the sexualization of children by guarding a "kid-friendly" drag show at a North Texas distillery;View Bill
US HR47SPORTSINTRODUCEDConcerning the National Collegiate Athletic Association policy for eligibility in women's sports.The House of Representatives (1) calls on the National Collegiate Athletic Association (referred to in this resolution as "NCAA") to revoke its transgender student-athlete eligibility policy that directly discriminates against female student athletes;View Bill
US SB209HEALTHCAREINTRODUCEDA bill to protect children from medical malpractice in the form of gender-transition procedures.View Bill
US SB312HEALTHCAREINTRODUCEDA bill to establish a Federal tort against pediatric gender clinics and other entities pushing gender-transition procedures that cause bodily injury to children or harm the mental health of children.View Bill
US SB74SPORTSINTRODUCEDFair Play for Girls ActA bill to require the Attorney General to submit to Congress a report relating to violence against women in athletics.View Bill
US SB9SPORTSINTRODUCEDProtection of Women and Girls in Sports Act of 2025A bill to provide that for purposes of determining compliance with title IX of the Education Amendments of 1972 in athletics, sex shall be recognized based solely on a person's reproductive biology and genetics at birth.To provide that for purposes of determining compliance with title IX of the Education Amendments of 1972 in athletics, sex shall be recognized based solely on a personâs reproductive biology and genetics at birth.View Bill
US SR21SPORTSINTRODUCEDA resolution designating October 10, 2025, as "American Girls in Sports Day".Whereas the National Association of Intercollegiate Athletics (NAIA) has instituted new policies to protect biological girls in sports and ensure that only student athletes whose biological sex is female will be allowed to compete in NAIA-sponsored women's sports teams; Whereas it is imperative that women's and girl's opportunities to compete athletically are protected; and Whereas October 10th, as represented by the Roman numerals "XX", signifies the female XX chromosomes: Now, therefore, be it Resolved, That the Senateâ (1) recognizes October 10, 2025, as "American Girls in Sports Day"; [...] (3) recognizes the importance of Title IX in protecting biological women in sports; and (4) calls on sports-governing bodies in the United States and abroad to protect biological women and girls in sports.View Bill
US SR22SPORTSINTRODUCEDA resolution concerning the National Collegiate Athletic Association policy for eligibility in women's sports.The House of Representatives (1) calls on the National Collegiate Athletic Association (referred to in this resolution as "NCAA") to revoke its transgender student-athlete eligibility policy that directly discriminates against female student athletes;View Bill
step 2: group challenge: pick out information from each bill card#
Now that we have narrowed down our data to bill_cards
, we can search within this code for the individual elements we want. For our dataset, we want to scrape the following information:
bill title
bill caption (if it exists!)
bill category
bill description
link to bill
Using the inspector, take 5-10 minutes create a list of html elements and attributes that correspond to the above information. Work in partners.
Once we have the code for the relevant HTML elements, we will now extract them and save them. To do that, we will write a loop that goes through each item in our bill_cards
, gets the relevant HTML element, and saves it to a variable. Our loop will goes through each bill card, one by one, and pull out the title, description, category, and link.
Note: loops are ways of programmatically going through a dataset and doing something to each item in the dataset, like extracting it. Read more about loops in the intro workshop
Below, I will be explaining the code logic in by writing it out in âpseudo-codeâ in the comments. Pseudo-code is a cross between normal language and programming language, that is useful for explaining and working out how to write the actual programming code in Python.
# for each card in bill_cards:
# get the title in h3.text
# get the category in span.text
# get the caption in h2.text
# get the descriptoin in p.text (if any)
# get the link in a tag, class "chakra-link"
# runs the loop on the bill cards
bill_cards = soup.find_all('div', class_ ='css-4rck61')
for item in bill_cards[:10]: # only the first ten cards, just to check if it is working
print(item.h3.text) # title
print(item.span.text) # category
print(item.h2.text) # caption
print(item.p.text) # description (if any)
print(item.a['href']) # add https://translegislation.com/bills/2023/US
US HB1064
MILITARY
Ensuring Military Readiness Act of 2023
To provide requirements related to the eligibility of transgender individuals from serving in the Armed Forces.
/bills/2024/US/HB1064
US HB1112
MILITARY
Ensuring Military Readiness Act of 2023
To provide requirements related to the eligibility of individuals who identify as transgender from serving in the Armed Forces.
/bills/2024/US/HB1112
US HB1276
HEALTHCARE
Protect Minors from Medical Malpractice Act of 2023
To protect children from medical malpractice in the form of gender transition procedures.
/bills/2024/US/HB1276
US HB1399
HEALTHCARE
Protect Childrenâs Innocence Act
To amend chapter 110 of title 18, United States Code, to prohibit gender affirming care on minors, and for other purposes.
/bills/2024/US/HB1399
US HB1490
INCARCERATION
Preventing Violence Against Female Inmates Act of 2023
To secure the dignity and safety of incarcerated women.
/bills/2024/US/HB1490
US HB1585
EDUCATION
Prohibiting Parental Secrecy Policies In Schools Act of 2023
To require a State receiving funds pursuant to title II of the Elementary and Secondary Education Act of 1965 to implement a State policy to prohibit a school employee from conducting certain social gender transition interventions.
/bills/2024/US/HB1585
US HB216
EDUCATION
My Child, My Choice Act of 2023
To prohibit Federal education funds from being provided to elementary schools that do not require teachers to obtain written parental consent prior to teaching lessons specifically related to gender identity, sexual orientation, or transgender studies, and for other purposes.
/bills/2024/US/HB216
US HB3101
OTHER
TPA Act Traditional Passport Act
To prohibit the issuance of a passport with any gender designation other than "male" or "female", and for other purposes.
/bills/2024/US/HB3101
US HB3102
OTHER
TSA Act Traditional Screening Application Act
To prohibit the Transportation Security Administration from using the "X" gender designation in the TSA PreCheck advanced security program, and for other purposes.
/bills/2024/US/HB3102
US HB3328
HEALTHCARE
Protecting Children From Experimentation Act of 2023
To amend chapter 110 of title 18, United States Code, to prohibit gender transition procedures on minors, and for other purposes.
/bills/2024/US/HB3328
Excellent work! In the next section, we will write some code to save this data in the form of a spreadsheet, a csv
file.