How can i call URL's from text file one by one
<p>I want to parse on one website with some URL's and i created a text file has all links that i want to parse. How can i call this URL's from the text file one by one on python program. </p>

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

soup = BeautifulSoup(requests.get("https://www.example.com").content, "html.parser")

for d in soup.select("div[data-selenium=itemDetail]"):
    url = d.select_one("h3[data-selenium] a")["href"]
    upc = BeautifulSoup(requests.get(url).content, "html.parser").select_one("span.upcNum")
    if upc:
        data = json.loads(d["data-itemdata"])
        text = (upc.text.strip())
        print(upc.text)
        outFile = open('/Users/Burak/Documents/new_urllist.txt', 'a')
        outFile.write(str(data))
        outFile.write(",")
        outFile.write(str(text))               
        outFile.write("\n")
        outFile.close()
</code></pre>

<p><strong>urllist.txt</strong></p>

<pre><code>https://www.example.com/category/1
category/2
category/3
category/4
</code></pre>

<p>Thanks in advance</p>

<p>Use a context manager :</p>

<pre><code>with open("/file/path") as f:
    urls = [u.strip('\n') for u in f.readlines()]
</code></pre>

<p>You obtain your list with all urls in your file and can then call them as you like.</p>

python parsing web-scraping beautifulsoup