Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 what is wrong with this code?
#1
Smile

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)
   
Quote
#2
markayala Wrote:I'm getting a TypeError: 'str' object is not callable and don't know how to solve it.
It is important that you post the whole error message that python prints in the console. This error message contains crucial information as to where exactly the error occurs in the code. If you want good help, please post everything after "Traceback, most recent call last ..."
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  I can't understand what's wrong with me? please help me!!! 573462273 1 892 Jul-07-2018, 08:08 PM
Last Post: Larz60+
  Wrong output in python3 via terminal on mac obligato 2 567 Jun-25-2018, 12:24 AM
Last Post: snippsat
  Am I going about this wrong? Oliver 0 652 Feb-27-2018, 04:31 PM
Last Post: Oliver

Forum Jump:


Users browsing this thread: 1 Guest(s)