{"id":18736,"date":"2023-06-06T08:27:35","date_gmt":"2023-06-06T06:27:35","guid":{"rendered":"https:\/\/www.graviton.at\/letterswaplibrary\/117th-u-s-congress-bill-full-text-data-scrap\/"},"modified":"2023-06-24T10:35:06","modified_gmt":"2023-06-24T08:35:06","slug":"117th-u-s-congress-bill-full-text-data-scrap","status":"publish","type":"post","link":"https:\/\/www.graviton.at\/letterswaplibrary\/117th-u-s-congress-bill-full-text-data-scrap\/","title":{"rendered":"117th U.S. Congress Bill Full Text Data Scrap?"},"content":{"rendered":"<p><!-- SC_OFF --><\/p>\n<div class=\"md\">\n<p>I&#8217;m looking to scrap the full text for all the proposed bills from the 117th Congress. I want to run the data through NVIVO for content analysis. I tried just downloading all the texts individually from <a href=\"https:\/\/congress.gov\/\">Congress.gov<\/a>, but I am looking to have all 15,224 documents available for analysis so the one-by-one approach is really unrealistic. I haven&#8217;t been able to find this data in a pre-existing dataset, but any assistance would be greatly appreciated!<\/p>\n<p>Of note, I have tried utilizing the <a href=\"https:\/\/congress.gov\/\">Congress.gov<\/a> API but I can&#8217;t figure out how to get all proposed texts. I then tried to run a python script in Google Collab, but I kept getting a &#8220;gaierror&#8221; error that I couldn&#8217;t resolve. I&#8217;ve also tried ProPublica and <a href=\"https:\/\/govtrack.us\/\">govtrack.us<\/a> but I couldn&#8217;t find a bulk data download option &#8212; only a bulk data query for view. I would still have to individually download each bill.<\/p>\n<p>Reference Python Script:<\/p>\n<p>#I removed my API key for privacy purposes, but I assure you it was in the script when I ran it<\/p>\n<p>\u200b<\/p>\n<p>import requests<\/p>\n<p>import json<\/p>\n<p>def get_bill_data(congress_number):<\/p>\n<p>base_url = &#8220;<a href=\"https:\/\/api.govinfo.gov\/\">https:\/\/api.govinfo.gov<\/a>&#8220;<\/p>\n<p>endpoint = &#8220;<a href=\"https:\/\/api.congress.gov\/v3\/bill\/117\/hr\/1\/text?api%5C_key=DEMO%5C_KEY%22.format(congress%5C_number)\">https:\/\/api.congress.gov\/v3\/bill\/117\/hr\/1\/text?api_key=DEMO_KEY&#8221;.format(congress_number)<\/a><\/p>\n<p>api_key = &#8220;[SQUATTINGFOX_API_KEY]&#8221; <\/p>\n<p>url = base_url + endpoint<\/p>\n<p>headers = {<\/p>\n<p>&#8220;X-API-KEY&#8221;: api_key,<\/p>\n<p>&#8220;Content-Type&#8221;: &#8220;application\/json&#8221;<\/p>\n<p>}<\/p>\n<p>response = requests.get(url, headers=headers)<\/p>\n<p>if response.status_code == 200:<\/p>\n<p>data = response.json()<\/p>\n<p>return data<\/p>\n<p>else:<\/p>\n<p>print(&#8220;Error retrieving bill data. Status Code:&#8221;, response.status_code)<\/p>\n<p>return None<\/p>\n<p>def save_bill_data(data, output_file):<\/p>\n<p>with open(output_file, &#8216;w&#8217;) as file:<\/p>\n<p>json.dump(data, file)<\/p>\n<p>congress_number = &#8220;117&#8221;<\/p>\n<p>output_file = &#8220;bills_data.json&#8221;<\/p>\n<p>bill_data = get_bill_data(congress_number)<\/p>\n<p>if bill_data:<\/p>\n<p>save_bill_data(bill_data, output_file)<\/p>\n<p>print(&#8220;Bill data saved to&#8221;, output_file)<\/p>\n<\/div>\n<p><!-- SC_ON -->   submitted by   <a href=\"https:\/\/www.reddit.com\/user\/squattingfox\"> \/u\/squattingfox <\/a> <br \/> <span><a href=\"https:\/\/www.reddit.com\/r\/datasets\/comments\/141modf\/117th_us_congress_bill_full_text_data_scrap\/\">[link]<\/a><\/span>   <span><a href=\"https:\/\/www.reddit.com\/r\/datasets\/comments\/141modf\/117th_us_congress_bill_full_text_data_scrap\/\">[comments]<\/a><\/span><\/p><div class='watch-action'><div class='watch-position align-right'><div class='action-like'><a class='lbg-style1 like-18736 jlk' href='javascript:void(0)' data-task='like' data-post_id='18736' data-nonce='65e0e39b87' rel='nofollow'><img class='wti-pixel' src='https:\/\/www.graviton.at\/letterswaplibrary\/wp-content\/plugins\/wti-like-post\/images\/pixel.gif' title='Like' \/><span class='lc-18736 lc'>0<\/span><\/a><\/div><\/div> <div class='status-18736 status align-right'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m looking to scrap the full text for all the proposed bills from the 117th Congress. I&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85],"tags":[27],"class_list":["post-18736","post","type-post","status-publish","format-standard","hentry","category-datatards","tag-english","wpcat-85-id"],"_links":{"self":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts\/18736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/comments?post=18736"}],"version-history":[{"count":1,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts\/18736\/revisions"}],"predecessor-version":[{"id":19401,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/posts\/18736\/revisions\/19401"}],"wp:attachment":[{"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/media?parent=18736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/categories?post=18736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.graviton.at\/letterswaplibrary\/wp-json\/wp\/v2\/tags?post=18736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}