How to make a bot to navigate a site? [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 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)

Related

Custom user registration in Wordpress [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 2 years ago.
Improve this question
I would like to set up user system in Wordpress, which is not limited to writing post or comment. Instead I would like to store custom user data (in my case users are tutors) for example the subject they teach and the price they charge. How could i do it with PHP or Sql?
You have two options here:
A) modify the registration form/process and request the users/tutors to input additional data when they register on the site; this will also require you to provide them with a user friendly interface screen where they can update/edit their information. What I usually do is create a view to display the user's info on the front end and then when loading that page check if the user is viewing their own profile and if so, load additional edit options in line with their data - I then use AJAX to allow them to update their own info.
B) if you want to manually manage this info yourself then simply have the users/tutors fill out a form and then you can update/edit a custom post-type called sevenine-tutor that you'll have to register/create in the system.
In theory you'd want these users managing their own profiles so option A) is probably the right route to pursue.
Questions like this are hard to answer because they're purely theoretical so there could be numerous ways to tackle them and whether an answer is correct or not is purely subjective. My advice would be to break your idea up into chunks and try tackling functions one by one and if you get stuck on something, then post relevant code here or to wordpress.stackexchange.com and get answers to very specific technical questions.

How to make a user be able to see and change the info on their account? [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
How would you make it so that a user is able to check their account information that is saved in the database and edit it? Let's say a user clicks on their account info page, it would display something like:
Username [abc]
Email: [aba#aba.abc]
Age: [20]
[Save Button]
When the user loads up the page, they would be able to see their information for those specified fields from the database. However, all this information would be in editable field that could be re-typed and saved.
So how would I go about doing this? What would this look like in PHP? I do not know how to display data from the databse onto a page, and I would imagine I would ned to do that. Also, does this data (that is being displayed on the page) need to be sanitized like how it was when the account was created?
There are many ways to approach this and unless necessary theres no need to reinvent the wheel.
A good place to start would be looking at the many open source projects that are out there such as:
UserFrosting - Modern user management for PHP #http://www.userfrosting.com
PHP Login #http://www.php-login.net
Alternativley frameworks such as Laravel, Yii2 and Symfony are a good environment to build these sort of systems in. With Laravel for example almost everything is configured for you out of the box. The authentication configuration file is located at config/auth.php, which contains several well documented options for tweaking the behavior of the authentication services.
After looking at these if you did decide you wanted to start from the ground up with your own design then there are many good in depth tutorials freely available online such as http://www.ineedtutorials.com/code/php/complete-advanced-login-member-system-php-tutorial
I hope my reply helps.

How to avoid someone to fetch my database? [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 8 years ago.
Improve this question
I have video website and I worry about if somebody write a script that fetches all my database and use it because i use the video id in address as query string for saying every page which video have to be shown.
Example:
http://example.com/video/215/videotitle
215 is my video id and videotitle is the title of my video, i want to have something like youtube:
www.youtube.com/watch?v=__zj6ibrq04
How can I do this?
i should mention that I used mod_rewrite to get an address like this so I absolutely worry about somebody fetching my database because they can know the video id.
That's awful because id is an auto increment primary key in my database!!!
Is there any suggestion?
If all your pages are public, i.e. anyone can go to any site at any time, there's only one thing you can do against a bot automatically scraping your site: detect scraping behaviour and throttle it. That means you need to track every visitor by IP address and/or other characteristics and start denying them access once they start requesting too many pages within a certain time window. No, this is not trivial to get right.
In this case it doesn't really matter what your URLs look like; you may think that YouTube's URLs are "unguessable", but (most of) YouTube's videos are entirely public and can be discovered by browsing through YouTube's front page. There's no need to guess the URL, that's an irrelevant detail. And even if they were not, you could simply start trying every single URL from __aaaaaaaa trough __9999999. It'll take a while, but it's possible.

What do I use to Enter, Retrieve, and/or Edit Project Details? [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 8 years ago.
Improve this question
I'm new to coding, so I'm having trouble knowing what to even search for to make my project work.
For our small construction company, I'm trying to build something that will store our project details; a database I suppose. As the title suggests, I need to be able to add new projects, retrieve past projects, or edit current projects.
In my mind, this can all be done on the same web page with the same form and maybe only a save button. So if I need to add a new job, I simply start typing the new job name. To retrieve a past job, I also simply start typing the name and autocomplete would find the record and bring up the details. Once it's loaded, if I need to edit something I scroll to the input, make my change and hit save.
Everything I've managed to find, so far, either costs money or is too clunky for my co-workers to feel comfortable using. And I feel like this is a relatively simple project, I just don't know where to start or what to learn.
My recommendations to you to accomplish this task would be either to:
Start learning HTML for the markup of your website and forms.
Continue with adding CSS to make the page more user friendly
Add some Javascript for validations and visual enhancements
Use MySql to store the information you need in a database
Add PHP to make the website dynamic and interact with the database
Some AJAX would really enhance the experience along with 3rd party libraries like jQuery
OR
another solution would be to hire a professional to do that for you, as that what i would do if i wanted to build a house, i would find a construction company such as yours instead of trying to do it all by myself without the know how and experience in the field as it would probably take me a lifetime to do it...

automaticly using someones online search database [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 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...

Categories