r/web_programming • u/hokoridustdrinker • Feb 14 '17
My First Website - How to process data server-side on a Wordpress shared host
I haven't written HTML since 1999, so I am obviously not a professional web developer. I am, however, creating a website and I believe that what I want to accomplish is relatively straightforward for someone who knows more about this than I do.
I want to:
receive text data from a series of web forms;
Use some/all of this text as input to a [first] third party webpage (it gets typed/pasted into a box and you click a button.
Receive/capture the output from the first third party website that results from clicking the button (in this case, a plurality of keywords extracted from the text input)
Use the obtained keywords as input to a [second] third party website (e.g, wikipedia)
retrieve the top result(s) from the second third party website
use the original text input and the info obtained from the second third party website to automatically generate/assemble a document.
Provide a locked preview of the document to the user. (so they could see what it looked like but not download it)
After checkout, provide the user with digital copies of the document (e.g., pdf, word, etc. for download).
Currently, I was trying to piece together as many commercial products as necessary in order to get it up and running as fast as possible. I used to have the website with squarespace, but it seemed that their CMS would be too limiting, so I moved to a shared host with a Wordpress CMS. I can create the forms manually or maybe with something like Jotforms to save time. I could store the text input as a text file, in a google sheet, or maybe some type of database. Then I would run a first script on the server to communicate with the first third party server, and a second script for the second third party server. The information obtained by these scripts could be stored in the same place as the text input. Then I could use some type of HotDocs solution to assemble the document. I'm not sure how to accomplish document preview or delivery. I was planning on using PaymentSphere as my payment processor.
My questions are:
Is this possible
What language should the scripts be written in? PHP? Python? Square space said that data manipulation would need to be done with javascript and Ajax calls to the other location where I've got the form.
How should the data be stored?
How do I accomplish the document preview feature?
How do you provide a link to download a file after checkout.
I am interested and capable of learning, but I have a specific purpose and do not need to become generally proficient. I just need to piece together and modify things to get it functional. Any help is very much appreciated.
1
u/BinaryRockStar Feb 14 '17
I think the first question you should ask is whether this is legal. You haven't named the sites themselves, but I can imagine scraping data off a website and selling the result is at the very least breaching the Terms of Service and quite possibly copyright infringement for profit.
To answer your other questions:
Yes it's possible. I would use Python over PHP but more so because I know it has ready-made libraries (requests, beautifulsoup, flask-wtforms) for doing some of the stuff you want. You have three ways of accessing data from a third-party website in increasing levels of complexity:
Access their API. If they have an open API you can use to query their data, it would be best to go this route as it's cleaner and less error prone.
Make HTTP requests to their web server and parse the result. With FF/Chrome Network/Dev Tools open, perform the search manually and see what sort of request the page is making to its server. Mimic this request using the
requestslibrary and parse the result using BeautifulSoup if the result is HTML, otherwise parse it as JSON or XML if that's what's returned.Programmatically control a running web browser using Selenium WebDriver. This library allows you to control a browser, for example "go to google.com, type 'Foo' into the text box, click the Search button, retrieve the top ten links". You have to specify the exact HTML elements you're talking about in XPath or CSS but it's relatively straightforward. This would require the server to have a connected physical or virtual monitor so it can run a real web browser application. If the third-party website has valuable data, expect them to quickly notice it's a machine operating their site not a person and banning your account.