Aug-06-2019, 07:50 AM
I made a python script to take data from a file, visit a web site using the data in the request, and save a specific text returned from the site in another file.
But I'm getting a TypeError: 'str' object is not callable and don't know how to solve it.
PS: I'm still learning python, and this is the first script I ever made.
from urllib.request import urlopen
import requests
# for Python 3: from urllib.request import urlopen
from bs4 import BeautifulSoup
import os
import urllib.request
#x=open("demofile.txt", "r")
#with open('demofile.txt', 'r') as fx:
# for line in fx
with open('demofile.txt', 'r') as fx:
for lines in fx.readlines():
with urllib.request.urlopen('http://api1.5sim.net/stubs/handler_api.php?api_key=XXXXXXX&action=getStatus&id='+lines) as data:
soup = BeautifulSoup(data.read(),'lxml').text
xt =soup.split(':')[1]
with open ('pin.txt','w')as writer:
for pins in xt:
writer.writelines(pins)
print(xt)
