here some difficulties with running python script through apache mod-php
fname='/tmp/catalog.xml'
http=urllib3.PoolManager()
response=http.request('GET','https://xxxx/xxxxx.xml')
doc=response.data.decode('UTF-8')
print('Saving xml...')
with open(fname,'w') as catalog:
catalog.write(doc)
print('Parsing...')
this code executed from php script and perfectly works when i execute it from cli like that : sudo -u www-data php -f test.php , in the tmp directory appears file catalog.xml with data in it. but when i execute same php script though web browser, the result from executing just string "Saving xml...", and empty file catalog.xml in the tmp directory. somehow data did not written in the file, but it creates
all permissoins are correct, file creates but it is empty, there is no errors at all in the php log file
problem solved. it was encoding problem. very strange that it works great in the cli and won't in mod-php. i just add encoding='utf-8'
fname='/tmp/catalog.xml'
http=urllib3.PoolManager()
response=http.request('GET','https://xxxx/xxxxx.xml')
doc=response.data.decode('UTF-8')
print('Saving xml...')
with open(fname,'w',encoding='utf-8') as catalog:
catalog.write(doc)
print('Parsing...')
and it works!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With