I am trying to write some code for a project in python 3.5. I have an API script which is written in php. I want to use this script in my python code. I am looking for a way but I could not find one yet.
Here is my python code:
#Loading Libraries
import urllib
import os
import time
from urllib.parse import urlparse
from urllib.parse import urljoin
from collections import Counter
import urllib.request
from bs4 import BeautifulSoup
id= 1
url='http://scitechdaily.com/new-technique-reveals-internal-characteristics-of-photonic-crystals/'
def GetArticles(url,id):
file = open('C:\\Users\\Hassan Raza\\Desktop\\Mozilla tech article\\Article'+'.txt', 'w')
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
htmlpage = urllib.request.urlopen(req)
html = htmlpage.read().decode('utf-8')
soup = BeautifulSoup(html,"html.parser")
title= soup.find_all('h1', {'class','title'})
for titles in title:
print(titles.text)
text = soup.find_all('div' , {'class', 'entry'})
for pg in text:
textdata = pg.text.encode('utf8')
############ Here I want to pass textdata to an API which is wirtten in PHP##########################
file.close()
GetArticles(url,id)
Please let me know how to use a php script in python so I can compete my project.
</div>