I'd like to have this script loop through a list of URLs and use a web scraper to search certain things from each of these websites. I have my cursor set up as well as Beautiful soup, but I'm wondering how I identify each item in the list? Can I attach an index number to each one somehow? Here's what I have. If I run this it will print the URLs. I've used Beautiful Soup to find things in HTML before, but I'm not sure how to find things from URLs in a list?
<SPAN class="keyword token">from</SPAN> bs4 <SPAN class="keyword token">import</SPAN> BeautifulSoup
<SPAN class="keyword token">import</SPAN> urllib
<SPAN class="keyword token">import</SPAN> urllib<SPAN class="punctuation token">.</SPAN>request
<SPAN class="keyword token">import</SPAN> os<SPAN class="punctuation token">,</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> time
<SPAN class="comment token">#the hosted layer with website urls in 'Website' field</SPAN>
fc <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'https://services.arcgis.com/fGsbyIOAuxHnF97m/arcgis/rest/services/Grab_Go_School_Meals_Location_(View)/FeatureServer/0?token=fbpCfA34sTJ4rzWO2TQn_c38B4TfGWOZ6jTMeFL1m7CNKd9_odI1t_t_hL-YvvePbE3M428FRT-zW-bISRYrGdJ2CnloKrHoHAfMnbGXpJ-5-zZBU6ONK1u0hMv5D-Vy-fnRpqpQP3aiQEke8L9d9jxDVBKWPamqCa0z0ko4IZX3xpIpHPSEKpmwpcJEaK7Z_rai3IBsT5-tqfMKIxnGCwe4SZZED8bDZM9j1T55-LggpjCgpwqWODs4vpj58iMy'</SPAN>
<SPAN class="comment token">#query the webpage and return the html to the variable'soup'</SPAN>
html <SPAN class="operator token">=</SPAN> urllib<SPAN class="punctuation token">.</SPAN>request<SPAN class="punctuation token">.</SPAN>urlopen<SPAN class="punctuation token">(</SPAN>url<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#parse the downloaded homepage and grab all text</SPAN>
soup <SPAN class="operator token">=</SPAN> BeautifulSoup<SPAN class="punctuation token">(</SPAN>html<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'html.parser'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#use current time to detect change</SPAN>
t <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>ctime<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Search Cursor</SPAN>
<SPAN class="comment token">#fc field where URLs are stored</SPAN>
field <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"Website"</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN> field<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">##BeautifulSoup</SPAN>
<SPAN class="comment token">##count the number of '<h1>' tags in HTML</SPAN>
n <SPAN class="operator token">=</SPAN> len<SPAN class="punctuation token">(</SPAN>soup<SPAN class="punctuation token">.</SPAN>find_all<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'h2'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>n<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#the text of the 26th '<h2>' tag</SPAN>
atts <SPAN class="operator token">=</SPAN> soup<SPAN class="punctuation token">.</SPAN>find_all<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'h2'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">20</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>text<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'http://www.manhattan114.org/index.php/download_file/view/2776/1/'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'http://www2.nlsd122.org/files/district/parentsandstudents/message_from_superintendent/2019-2020/mfts_031720.pdf'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'https://www.peotoneschools.org/UserFiles/Servers/Server_266769/File/COVID-19%20Email%203.15.20.pdf'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'https://manteno5.org/news/what_s_new/c_o_v_i_d-19_updates'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'https://www.joliet86.org/student-grab-and-go-meals-available/'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'https://www.joliet86.org/student-grab-and-go-meals-available/'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'https://www.joliet86.org/student-grab-and-go-meals-available/'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'https://www.joliet86.org/student-grab-and-go-meals-available/'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>