0

Trying to send data loaded into a variable from a python program into another. The relevant code is below.

file data is being created:

import requests
from privateDiningParser import isPrivateD

from pydal import DAL, Field
from lxml import etree


r = requests.get(urlCheck)

if r.status_code == 404:
     print ('No private dining information')

else:
     print('Parsing private dining information')
     isPrivateD(urlCheck)

File data is going to:

import requests
from lxml import etree

url = ''

def isPrivateD(privateUrl):

    url = privateUrl

parser = etree.HTMLParser()

tree = etree.parse(url,parser)
root = tree.getroot()

The Expected result is:

print('You made it' + privateUrl) #Testing to see if files connected

This is the error I am getting:

    tree = etree.parse(url,parser)
  File "lxml.etree.pyx", line 3239, in lxml.etree.parse (src/lxml/lxml.etree.c:69955)
  File "parser.pxi", line 1748, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:102066)
  File "parser.pxi", line 1774, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:102330)
  File "parser.pxi", line 1678, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:101365)
  File "parser.pxi", line 1110, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:96817)
  File "parser.pxi", line 582, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:91275)
  File "parser.pxi", line 683, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:92461)
  File "parser.pxi", line 620, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:91722)
IOError: Error reading file '': failed to load external entity ""

Thank you all, I apologise if the question is trival, 2 hours later on various docs and still can't figure out what I am doing wrong

  • 1
    Does this need to be done in real time (simultaneously which requires interprocess communication) or is the file created then being read (simple file IO)? There's a wide gap in complexity. – Al Wang Jul 27 '15 at 22:32
  • It's difficult to provide answers since you do not provide the expect and actual results. – Nathan Davis Jul 27 '15 at 22:34
  • Not shown but urlCheck is grabbed in a for loop, so each iteration UrlCheck is changed to a different value. So isPrivateD and the file it is within, need to be executed with each iteration of the for loop in the orginal file. – Christopher Jakob Jul 27 '15 at 22:35
  • possible duplicate of [How to call a function from another file in Python?](http://stackoverflow.com/questions/20309456/how-to-call-a-function-from-another-file-in-python) – YXD Jul 27 '15 at 22:37
  • not even close @YXD come on now – Christopher Jakob Jul 27 '15 at 22:41
  • 1
    Your question is really hard to understand. Can you try to explain in simple words what you're trying to do? You have one script which produces a URL and prints it to stdio, and you want to pipe this output to a second script? – maxymoo Jul 27 '15 at 22:46
  • Sure, so the call in the first file is in a for loop which is not shown. The for loop has a value which changes with each iteration. I want to take that value and see if it returns a website page, if it does then I want to send the url with the value appended to it to a webpage parser in the next file for it to do work on the webpage. Alot of the code I am talking about is omitted, as it isn't relevant to the problem – Christopher Jakob Jul 27 '15 at 22:55

1 Answers1

0

Got it to work,

the problem was in the file I was sending the info to. only some of the code in the second file was in a method the rest was acting as a script, I cant have one or the other. fixed and working. Hugs and kisses