For Loop doesn't spit out needed results
<p>I got this piece of code to spit out the unique "area number" in the URL. However, the loop doesn't work. It spits out the same number, please see below:</p>

<pre><code>import urllib3
from bs4 import BeautifulSoup

http = urllib3.PoolManager()

url = open('MS Type 1 URL.txt',encoding='utf-8-sig')

links = []
for link in url:
    y = link.strip()
    links.append(y)

url.close()

print('Amount of Links: ', len(links))

for x in links:
    j = (x.find("=") + 1)
    g = (x.find('&amp;housing'))
    print(link[j:g])
</code></pre>

<p>Results are:</p>

<p><a href="http://millersamuel.com/aggy-data/home/query_report?area=38&amp;housing_type=3&amp;measure=4&amp;query_type=quarterly&amp;region=1&amp;year_end=2020&amp;year_start=1980" rel="nofollow">http://millersamuel.com/aggy-data/home/query_report?area=38&amp;housing_type=3&amp;measure=4&amp;query_type=quarterly&amp;region=1&amp;year_end=2020&amp;year_start=1980</a>
23</p>

<p><a href="http://millersamuel.com/aggy-data/home/query_report?area=23&amp;housing_type=1&amp;measure=4&amp;query_type=annual&amp;region=1&amp;year_end=2020&amp;year_start=1980" rel="nofollow">http://millersamuel.com/aggy-data/home/query_report?area=23&amp;housing_type=1&amp;measure=4&amp;query_type=annual&amp;region=1&amp;year_end=2020&amp;year_start=1980</a>
23</p>

<p>As you can see it spits out the area number '23' which is only in one of this URL but not the '38' of the other URL.</p>

<blockquote>
  <p>You need to change: </p>
</blockquote>

<pre><code>print(link[j:g]) to print(x[j:g])
</code></pre>

python python-3.x loops beautifulsoup urllib3