automaticly using someones online search database [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Does anyone have any ideas for what would be the best way to automaticly use someones online search database, given a static search (see example). It might also make this question more usefull to add a solution for a none static search.
So for example, I have a website and I wan't to create a link to the PDF file of the latest report by a certain person on this site: http://aris.empr.gov.bc.ca The search criteria does not change, all that changes is new results as the database is updated, so the search result is always http://aris.empr.gov.bc.ca/search.asp?mode=find Notice that not all entries have a report yet.
So far my idea is to use a php script to search through the source code of the completed search result page, search for the first instance of a .pdf string, and then extract the whole link (the page is orderd by date, so the first pdf file found would be the latest report that has a pdf file available.
The problems with this solutions:
1) it is very specific to my problem and only works for a static search result, and so is not a good Q&A
2) I am not sure if the completed search link researches everytime you follow it, or if it leads to an old result that could become out to of date
3) my solution is not sexy and is held together by duct tape, if you know what I mean.
Thanks,
-Adrian

In real terms you want to scrape the page(s).
You have 2 options in PHP:
1. Use CURL to fetch the page and USE PHP DOM parser to parse and extract the content from it.
2. You can use PHP Simple DOM Library, check here : http://simplehtmldom.sourceforge.net
It has ready made functions and you won't need to use CURL much here.
I hope you get an idea.
Try some code, show us here and we will guide more on this...

Related

Create a link based on table date on another website [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am trying to think about how I would go about creating a link to something based on a data in another table on another website.
I have the following table on the other website:
https://i.imgur.com/Hlemt1y.jpg
so basically columns: Order #, Status, customer P-O
What I am trying to do is create a url based on "customer PO" that links to the Order #. So it would find the customer PO, then check the value on the same row of Order #, and then once I have that value I can create the URL using that order #.
I've never done anything that takes a value from another website so I guess that is what I am after?
If the other web page doesn't have an API that you can use to retrieve that data in a more usable format, you will have to use a technique known as scraping. you would likely use curl or wget to fetch the web page and then parse the resulting html page to pull the data you need out of it. an xml library would be able to assist in parsing, but you may be able to get away with a shortcut by searching the string for a common beginning and ending string.
so for example, if there is only one html table on the page, you can search for
<table>
and the matching
</table>
Then parsing the tr and td tags is a little more manageable than dealing with the entire page. In the end it just depends on what this is being used for and how robust it needs to be.

How to show Only a selected Number of Database entries on the page [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
The question is, if I have got 100 entries in my Database and want them all getting displayed on my page, how can I only show a selected Number like it's the case in webshops etc.
There you've got 37 products e.g. and after 10 products you have to select number 2 of the entry list.Its all split up in a few sites, but its still the same site.How can i achieve this.
You can achieve the pagination either by client side implementations or server side.
Client side (using Java Script/JQuery) and Server Side (using PHP) is preferable.
For client side, just follow this
link
For Server side
PHP Pagination
I notice that you put php, html and mysql as tags on your question so it's mean you don't have a clue on what you are doing. You should really study those things in separate a little more.
For the MySQL part you must study the limit directive.
The html part is not big deal also, you will have to make a pagination system. As said before Google is your friend.
On the server-side (php) you should look for the parameters/url on the page defined by the html part and make the proper query.
If I would enter in details of each of those steps I would have to write several paragraphs and still would be things missing. Well, at least I've given you directions, now you really should study more before attempting to do things like this.
Next time don't ask questions too vague/broad. Try to focus on specific issues rather than asking for the whole solution.

How to implement a database like search form into a website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
How can I go about implementing a database like search form into an HTML website? For example, there is a form to enter your zip code and after entering the zip code, it searches a .txt file (for example) and returns results that fall under that specific zip code.
Any help would be greatly appreciated.
Thank you
There are many approaches you could take. It's a very broad question.
As an example solution, you would need to have both client and server side code. The client would submit the form to a server. The server code could be written in a multitude of languages, PHP, ASP, JAVA etc.
The server side code would take the request parameters sent by the form, read the file, calculate any result and pass it back in the http response to the front end, which could be dealt with by displaying a new page or as part of an AJAX refresh.
As you can appreciate though, this is a very broad topic and there are many possible solutions.
Also as #Dagon points out, if you are not restricted to using a text file (although your title probably suggests you are) then using a MySQL or other such database could be a better solution, maybe even Solr as an indexing solution, depending on what you are searching for.

Simple Website Comments Section [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a very simple website, and would like to create a 'Comments' section to it. Currently I have a HTML document and a CSS document running the site.
I have a little knowledge of PHP, and would like to keep this as simple as possible - i.e: saving comments to a text file perhaps? But not sure.
Can someone please suggest the simplest way of adding the comments options in.
Thanks for any help.
You can use Facebook Connect to add comments to an existing page: http://developers.facebook.com/blog/post/472 (Updated Link)
I found that post by searching google for "add facebook comments to your site"
It requires a MySQL database (which, if you're developing with PHP, is something that's better to get a cursory knowledge of sooner rather than later), but Commentator is a pretty nice, simple comment script. See: http://ratherodd.com/commentator/
You actually can do this very easily using file_get_contents() and file_put_contents(). Using only a flat text file and no database.
I set up an example page at:
http://staticchaos.freeoda.com/php/

How to make a bot to navigate a site? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Given a product id, associates have to navigate a vendors website, log in, perform a search, in order to get details on a product for a customer.
My employers want a program that can use the product id, and navigate the vendors website, and perform the search and everything to get the information thus saving the associate from having to manually repeat this task every time a customer wants more information about a product.
I know many sites use methods to prevent (CAPTCHA) exactly what I am trying to do. So I do not know if that automatically makes my given project an "evil" one. But I certainly do not have evil intentions, my employers simply want to save associates time on getting information that they are going to get regardless. However, if this is "evil" please explain why, so I can explain to my employers why we should not go down this road. That being said...
How can I make something like this in PHP?
It depends on what site you are trying to access. Many sites have an API that can be used to access data. If that's not the case, you may need to write a program that loads the html using a GET request, parses through the response, and retrieves the information you want. Without more details, that's the best answer I can give.
To start with I'd recommend reading up on cURL and DOM
cURL: http://php.net/curl (for fetching pages, even simulating search form)
DOM: http://www.php.net/manual/en/book.dom.php (to parse the fetched pages)

Categories