Wednesday, 25 September 2013

A simple way to turn a website into JSON

Recently, while surfing the web I stumbled upon an simple web scraping service named Web Scrape Master. It is a kind of RESTful web service that extracts data from a specified web site and returns it to you in JSON format.
How it works

Though I don’t know what this service may be useful for, I still like its simplicity: all you need to do is to make an HTTP GET request, passing all necessary parameters in the query string:
http://webscrapemaster.com/api/?url={url}&xpath={xpath}&attr={attr}&callback={callback}

    url  - the URL of the website you want to scrape
    xpath – xpath determining the data you need to extract
    attr - attribute the name you need to get the value of (optional)
    callback - JSON callback function (optional)

For example, for the following request to our testing ground:

http://webscrapemaster.com/api/?url=http://testing-ground.extract-web-data.com/blocks&xpath=//div[@id=case1]/div[1]/span[1]/div

You will get the following response:

[{"text":"<div class='name'>Dell Latitude D610-1.73 Laptop Wireless Computer</div>","attrs":{"class":"name"}}]
Visual Web Scraper

Also, this service offers a special visual tool for building such requests. All you need to do is to enter the URL of the website and click to the element you need to scrape:
Visual Web Scraper
Conclusion

Though I understand that the developer of this service is attempting to create a simple web scraping service, it is still hard to imagine where it can be useful. The task that the service does can be easily accomplished by means of any language.

Probably if you already have software receiving JSON from the web, and you want to feed it with data from some website, then you may find this service useful. The other possible application is to hide your IP when you do web scraping. If you have other ideas, it would be great if you shared them with us.



Source: http://extract-web-data.com/a-simple-way-to-turn-a-website-into-json/

Tuesday, 24 September 2013

Selenium IDE and Web Scraping

Selenium is a browser automation framework that includes IDE, Remote Control server and bindings of various flavors including Java, .Net, Ruby, Python and other. In this post we touch on the basic structure of the framework and its application to  Web Scraping.
What is Selenium IDE


Selenium IDE is an integrated development environment for Selenium scripts. It is implemented as a Firefox plugin, and it allows recording browsers’ interactions in order to edit them. This works well for software tests, composing and debugging. The Selenium Remote Control is a server specific for a particular environment; it causes custom scripts to be implemented for controlled browsers. Selenium deploys on Windows, Linux, and iOS. How various Selenium components are supported with major browsers read here.
What does Selenium do and Web Scraping

Basically Selenium automates browsers. This ability is no doubt to be applied to web scraping. Since browsers (and Selenium) support JavaScript, jQuery and other methods working with dynamic content why not use this mix for benefit in web scraping, rather than to try to catch Ajax events with plain code? The second reason for this kind of scrape automation is browser-fasion data access (though today this is emulated with most libraries).

Yes, Selenium works to automate browsers, but how to control Selenium from a custom script to automate a browser for web scraping? There are Selenium PHP and other language libraries (bindings) providing for scripts to call and use Selenium. It is possible to write Selenium clients (using the libraries) in almost any language we prefer, for example Perl, Python, Java, PHP etc. Those libraries (API), along with a server, the Java written server that invokes browsers for actions, constitute the Selenum RC (Remote Control). Remote Control automatically loads the Selenium Core into the browser to control it. For more details in Selenium components refer to here.



A tough scrape task for programmer

“…cURL is good, but it is very basic.  I need to handle everything manually; I am creating HTTP requests by hand.
This gets difficult – I need to do a lot of work to make sure that the requests that I send are exactly the same as the requests that a browser would
send, both for my sake and for the website’s sake. (For my sake
because I want to get the right data, and for the website’s sake
because I don’t want to cause error messages or other problems on their site because I sent a bad request that messed with their web application).  And if there is any important javascript, I need to imitate it with PHP.
It would be a great benefit to me to be able to control a browser like Firefox with my code. It would solve all my problems regarding the emulation of a real browser…
it seems that Selenium will allow me to do this…” -Ryan S

Yes, that’s what we will consider below.
Scrape with Selenium

In order to create scripts that interact with the Selenium Server (Selenium RC, Selenium Remote Webdriver) or create local Selenium WebDriver script, there is the need to make use of language-specific client drivers (also called Formatters, they are included in the selenium-ide-1.10.0.xpi package). The Selenium servers, drivers and bindings are available at Selenium download page.
The basic recipe for scrape with Selenium:

    Use Chrome or Firefox browsers
    Get Firebug or Chrome Dev Tools (Cntl+Shift+I) in action.
    Install requirements (Remote control or WebDriver, libraries and other)
    Selenium IDE : Record a ‘test’ run thru a site, adding some assertions.
    Export as a Python (other language) script.
    Edit it (loops, data extraction, db input/output)
    Run script for the Remote Control

The short intro Slides for the scraping of tough websites with Python & Selenium are here (as Google Docs slides) and here (Slide Share).
Selenium components for Firefox installation guide

For how to install the Selenium IDE to Firefox see  here starting at slide 21. The Selenium Core and Remote Control installation instructions are there too.
Extracting for dynamic content using jQuery/JavaScript with Selenium

One programmer is doing a similar thing …

1. launch a selenium RC (remote control) server
2. load a page
3. inject the jQuery script
4. select the interested contents using jQuery/JavaScript
5. send back to the PHP client using JSON.

He particularly finds it quite easy and convenient to use jQuery for
screen scraping, rather than using PHP/XPath.
Conclusion

The Selenium IDE is the popular tool for browser automation, mostly for its software testing application, yet also in that Web Scraping techniques for tough dynamic websites may be implemented with IDE along with the Selenium Remote Control server. These are the basic steps for it:

    Record the ‘test‘ browser behavior in IDE and export it as the custom programming language script
    Formatted language script runs on the Remote Control server that forces browser to send HTTP requests and then script catches the Ajax powered responses to extract content.

Selenium based Web Scraping is an easy task for small scale projects, but it consumes a lot of memory resources, since for each request it will launch a new browser instance.



Source: http://extract-web-data.com/selenium-ide-and-web-scraping/

Monday, 23 September 2013

Web Data Extraction Services and Data Collection Form Website Pages

For any business market research and surveys plays crucial role in strategic decision making. Web scrapping and data extraction techniques help you find relevant information and data for your business or personal use. Most of the time professionals manually copy-paste data from web pages or download a whole website resulting in waste of time and efforts.

Instead, consider using web scraping techniques that crawls through thousands of website pages to extract specific information and simultaneously save this information into a database, CSV file, XML file or any other custom format for future reference.

Examples of web data extraction process include:
• Spider a government portal, extracting names of citizens for a survey
• Crawl competitor websites for product pricing and feature data
• Use web scraping to download images from a stock photography site for website design

Automated Data Collection
Web scraping also allows you to monitor website data changes over stipulated period and collect these data on a scheduled basis automatically. Automated data collection helps you discover market trends, determine user behavior and predict how data will change in near future.

Examples of automated data collection include:
• Monitor price information for select stocks on hourly basis
• Collect mortgage rates from various financial firms on daily basis
• Check whether reports on constant basis as and when required

Using web data extraction services you can mine any data related to your business objective, download them into a spreadsheet so that they can be analyzed and compared with ease.

In this way you get accurate and quicker results saving hundreds of man-hours and money!

With web data extraction services you can easily fetch product pricing information, sales leads, mailing database, competitors data, profile data and many more on a consistent basis.




Source: http://ezinearticles.com/?Web-Data-Extraction-Services-and-Data-Collection-Form-Website-Pages&id=4860417

Control Your Data Entry Cost

I am sure all will agree that a company's main motto would be to boost up the revenue and to derogate the expenses, to save time and to focus on the core business. For maintaining the data of the company with the all above can be achieved by using outsourcing method. The main benefits of outsourcing are cost effectiveness. This is brought about by the reduction in man power, infrastructure, investments on technologies and software.

Offshore outsourcing is still more cost effective as same benefits are obtained with the same quality level at much lower cost. It reduces the burden of standardizing the infrastructure and updating the software needed for the data maintenance by the company itself. Outsourcing improves the productivity level with quality and greatly changes the magnitude of profit level. The cut off of salary for the professional man power to maintain the data is the best cost control for a company. The capital investment is saved by removing off the expenditure for unnecessary fixed investments.

The best benefit from outsourcing can be obtained by choosing an outsourcing partner who is specifically specialized in particular business process. In this case the partner will be able to give out more proficient and good quality services. It also provides faster deliverables. Countries like U.S, U.K benefit the best out of outsourcing in offshore countries like India as they have the zone advantage. During the off time of the office, any critical work is done by the outsourcing partner and hence gives the business a competitive advantage.

Data Entry Services - VServe Solution provides services such as data entry, data capture, data processing, document management and data transcription.

Susan from Vserve Solution, working as Business Development Manager



Source: http://ezinearticles.com/?Control-Your-Data-Entry-Cost&id=2375184

Sunday, 22 September 2013

Data Mining, Not Just a Method But a Technique

Web data mining is segregating probable clients out of huge information available on the Internet by performing various searches. It could be well organized and structured, or raw, depending on the use of the data. Web data mining could be done using a simple database program or investing money in a costly program.

Start collecting basic contact information of probable clients, such as: names, addresses, landline and cell phone numbers, email addresses and education or occupation if required.

CART and CHAID data mining

While collecting data you will find that tree-shaped structures that represent decisions. These derived decisions give rules for the classification of data collected. Precise decision tree methods include Classification and Regression Trees also know as CART data mining and Chi Square Automatic Interaction Detection also known as CHAID data mining. CART and CHAID data mining are decision tree techniques used for classification of data collected. They provide a set of rules that could be applied to unclassified data collected in prediction. CART segments a dataset creating two-way splits whereas CHAID segments using chi square tests creating multi-way splits. CART requires less data preparation compared to CHAID.

Understanding customer's actions

Keep a track of customer's actions like: what does he buy, when does he buy, why does he buy, what is the use of his buying, etc. Knowing such simple things about your customer will help you to understand needs of your customer better and thus process of data mining services will be easier and quality data would be mined. This will increase your personal relations with your customer which would finally result in a better professional relationship.

Following demography

Mine the data as per demography, dependent on geography as well as socio economic background of business location. You can use government statistics as the source of your data collection. Keeping it in mind you can go ahead with the understanding of the community existing and thus the data required.

Use your informal conversation in serving your clients better

Use minute details of your conversation and understanding with your customers to serve them. If essential, conduct surveys, send a professional gift or use some other object that helps you understand better in fulfilling customer needs. This will increase the bonding between you and your customer and you will be able to serve your customer better in providing data mining services.

Insert the collect information in a desktop database. More the information is collected you will find that you can prepare specific templates in feeding information. Using a desktop database, it is easier to make changes later on as and when required.

Maintaining privacy

While performing, it is essential to ensure that you or your team members are not violating privacy laws in gathering or providing the data information. Once trust is lost, you may also loose the customer, because trust is the base of any relationship, let it be a business relation.

To fulfill your needs as a customer in data mining, you will not find a better source than http://www.onlinewebresearchservices.com. Help us to serve you better.




Source: http://ezinearticles.com/?Data-Mining,-Not-Just-a-Method-But-a-Technique&id=5416129

Friday, 20 September 2013

How to Rescue Data From Your Damaged Hard Drive

A damaged hard disk drive is one of the most unpleasant types of hardware failure. No, I don't mean that a burned processor or a damaged memory block are more enjoyable. Not at all - they are also disasters and in terms of money generally it is more expensive to replace a processor than to replace a hard drive but damaged hard drives have one very irritating property - you lose not only your hardware but also all or some of your data. Data is priceless and if you don't have a backup copy of it, then you are lost.

However, not all hard drive damages are that bad. There are cases when the hard drive is damaged but the data on it is alive. So, if your hard drive crashes, don't panic but hope for the best - i.e. the drive might have become an obsolete piece of machinery but at least your data is not buried inside. There are different strategies for evacuating data from a damaged hard drive and which one you can use depends on the sort of damage, as we'll see next.

What Is a Damaged Hard Drive A damaged hard drive come come in many flavors. In addition to that, there are many cases when the drive is not damaged but due to some reason the data can't be accessed. For a non-specialist all these cases might look the same - I can't access my files, so my hard drive must have gone off, while in reality the hard drive is perfectly OK but your data is inaccessible because of some prosaic reason.

Without getting into technical details, the shortest (and hardly most precise) explanation of a completely damaged hard drive is that this hard drive can't be accessed with any means even by a qualified PC technician. So, unless you are a PC technician yourself, you can't determine on your own if the hard drive is totally dead or not. However, since there are many cases when a drive is still alive but it can't be accessed due to a variety of reasons (most frequently software issues) you can try some of the approaches in the next section and see if they work. Even if they don't work, they will do no harm, but this does not mean you shouldn't be cautious when applying them.

What You Can Do on Your Own One of the cases when the hard drive is not physically damaged but is unaccessible due to software reasons is when the partition on which the data resides is inaccessible, or at least not from your operating system. In this case you can use an alternative operating system, for instance a Live CD with a Linux distribution and see if you will have more luck accessing the partition. This will work, if the partition table on your computer is not totally messed up. If you see that the data is still unaccessible, don't attempt to mess up with the partition table because you can make things worse. Instead, hurry up and find a PC technician and pray that he or she will be able to recover your data for you.

Another case when the data might still be alive is when the drive has been formatted on a high level. If the drive has been formatted on a low level, the extraction techniques will not work because the data has been physically destroyed. There are many tools to unformat a formatted drive. Most of the tools are paid ones but you can find free as well. Hiren's Boot CD comes with a bundle of data recovery tools and I generally prefer to use them than any other tools.

Software problems are common but hardware problems - I.e. bad sectors or a damaged controller are also not an exception. Unfortunately, there isn't much you can do about them. If data is sucked by a bad sector, then in 99% of the cases it is gone for good. The 1% stands for the rare chance that you have made copies of exactly this file and the copy is not on a bad sector but this is really a lucky exception. You can take the hard drive to a service but it is unlikely that they will be able to do much.

Another technique you can try on your own without risk to make the damage more severe is to go to your HDD manufacturer's site and see if they provide retrieval tools. Usually hard drive manufacturers provide diagnostic tools but if you are lucky, chances are that you will find a data retrieval tool as well. Very often the diagnostic tools themselves not only check for problems but they also can fix some issues, so they could help you save your data as well.

The above mentioned techniques to extract data from a damaged hard drive are only a small fraction of what can be done. However, many of the other techniques are more complicated and they do require some knowledge about a hard drive's architecture, so I wouldn't recommend you to apply them because you can make a lot of damage. Some of the techniques that require opening the computer case or messing with the parts of the disk itself are too dangerous to try at home. No, you will hardly destroy your home but you can surely further damage the hard drive, making it impossible even for a technician to help you. Additionally, you can void the warranty for the computer system, which is hardly what you want to achieve.

Take the Hard Drive to a PC Technician If you have tried to rescue the data from your hard drive on your own to no avail, you have no choice but to take it to a service. A PC service has more equipment than the standard user and there is a chance they will be able to help you but still, don't expect miracles. In some cases data extraction services could be free of charge, especially if you have bought the hard drive from them and the warranty has not expired yet but in other cases you will have to pay.

As you probably guess, fees vary. As a rule, the cost depends on the volume of data that needs to be extracted but generally it does not cost a fortune - you might be able find somebody to do it for around $200. Still, if your drive has serious physical damages, even if you go to a more expensive data rescue lab, there is no guarantee that your data can and will be restored.




Source: http://ezinearticles.com/?How-to-Rescue-Data-From-Your-Damaged-Hard-Drive&id=1620693

Thursday, 19 September 2013

Data Mining Models - Tom's Ten Data Tips

What is a model? A model is a purposeful simplification of reality. Models can take on many forms. A built-to-scale look alike, a mathematical equation, a spreadsheet, or a person, a scene, and many other forms. In all cases, the model uses only part of reality, that's why it's a simplification. And in all cases, the way one reduces the complexity of real life, is chosen with a purpose. The purpose is to focus on particular characteristics, at the expense of losing extraneous detail.

If you ask my son, Carmen Elektra is the ultimate model. She replaces an image of women in general, and embodies a particular attractive one at that. A model for a wind tunnel, may look like the real car, at least the outside, but doesn't need an engine, brakes, real tires, etc. The purpose is to focus on aerodynamics, so this model only needs to have an identical outside shape.

Data Mining models, reduce intricate relations in data. They're a simplified representation of characteristic patterns in data. This can be for 2 reasons. Either to predict or describe mechanics, e.g. "what application form characteristics are indicative of a future default credit card applicant?". Or secondly, to give insight in complex, high dimensional patterns. An example of the latter could be a customer segmentation. Based on clustering similar patterns of database attributes one defines groups like: high income/ high spending/ need for credit, low income/ need for credit, high income/ frugal/ no need for credit, etc.

1. A Predictive Model Relies On The Future Being Like The Past

As Yogi Berra said: "Predicting is hard, especially when it's about the future". The same holds for data mining. What is commonly referred to as "predictive modeling", is in essence a classification task.

Based on the (big) assumption that the future will resemble the past, we classify future occurrences for their similarity with past cases. Then we 'predict' they will behave like past look-alikes.

2. Even A 'Purely' Predictive Model Should Always (Be) Explain(ed)

Predictive models are generally used to provide scores (likelihood to churn) or decisions (accept yes/no). Regardless, they should always be accompanied by explanations that give insight in the model. This is for two reasons:

    buy-in from business stakeholders to act on predictions is of eminent importance, and gains from understanding
    peculiarities in data do sometimes arise, and may become obvious from the model's explanation


3. It's Not About The Model, But The Results It Generates

Models are developed for a purpose. All too often, data miners fall in love with their own methodology (or algorithms). Nobody cares. Clients (not customers) who should benefit from using a model are interested in only one thing: "What's in it for me?"

Therefore, the single most important thing on a data miner's mind should be: "How do I communicate the benefits of using this model to my client?" This calls for patience, persistence, and the ability to explain in business terms how using the model will affect the company's bottom line. Practice explaining this to your grandmother, and you will come a long way towards becoming effective.

4. How Do You Measure The 'Success' Of A Model?

There are really two answers to this question. An important and simple one, and an academic and wildly complex one. What counts the most is the result in business terms. This can range from percentage of response to a direct marketing campaign, number of fraudulent claims intercepted, average sale per lead, likelihood of churn, etc.

The academic issue is how to determine the improvement a model gives over the best alternative course of business action. This turns out to be an intriguing, ill understood question. This is a frontier of future scientific study, and mathematical theory. Bias-Variance Decomposition is one of those mathematical frontiers.

5. A Model Predicts Only As Good As The Data That Go In To It

The old "Garbage In, Garbage Out" (GiGo), is hackneyed but true (unfortunately). But there is more to this topic. Across a broad range of industries, channels, products, and settings we have found a common pattern. Input (predictive) variables can be ordered from transactional to demographic. From transient and volatile to stable.

In general, transactional variables that relate to (recent) activity hold the most predictive power. Less dynamic variables, like demographics, tend to be weaker predictors. The downside is that model performance (predictive "power") on the basis of transactional and behavioral variables usually degrades faster over time. Therefore such models need to be updated or rebuilt more often.

6. Models Need To Be Monitored For Performance Degradence

It is adamant to always, always follow up model deployment by reviewing its effectiveness. Failing to do so, should be likened to driving a car with blinders on. Reckless.

To monitor how a model keeps performing over time, you check whether the prediction as generated by the model, matches the patterns of response when deployed in real life. Although no rocket science, this can be tricky to accomplish in practice.

7. Classification Accuracy Is Not A Sufficient Indicator Of Model Quality

Contrary to common belief, even among data miners, no single number of classification accuracy (R2, Gini-coefficient, lift, etc.) is valid to quantify model quality. The reason behind this has nothing to do with the model itself, but rather with the fact that a model derives its quality from being applied.

The quality of model predictions calls for at least two numbers: one number to indicate accuracy of prediction (these are commonly the only numbers supplied), and another number to reflect its generalizability. The latter indicates resilience to changing multi-variate distributions, the degree to which the model will hold up as reality changes very slowly. Hence, it's measured by the multi-variate representativeness of the input variables in the final model.

8. Exploratory Models Are As Good As the Insight They Give

There are many reasons why you want to give insight in the relations found in the data. In all cases, the purpose is to make a large amount of data and exponential number of relations palatable. You knowingly ignore detail and point to "interesting" and potentially actionable highlights.

The key here is, as Einstein pointed out already, to have a model that is as simple as possible, but not too simple. It should be as simple as possible in order to impose structure on complexity. At the same time, it shouldn't be too simple so that the image of reality becomes overly distorted.

9. Get A Decent Model Fast, Rather Than A Great One Later

In almost all business settings, it is far more important to get a reasonable model deployed quickly, instead of working to improve it. This is for three reasons:

    A working model is making money; a model under construction is not
    When a model is in place, you have a chance to "learn from experience", the same holds for even a mild improvement - is it working as expected?
    The best way to manage models is by getting agile in updating. No better practice than doing it... :)


10. Data Mining Models - What's In It For Me?

Who needs data mining models? As the world around us becomes ever more digitized, the number of possible applications abound. And as data mining software has come of age, you don't need a PhD in statistics anymore to operate such applications.

In almost every instance where data can be used to make intelligent decisions, there's a fair chance that models could help. When 40 years ago underwriters were replaced by scorecards (a particular kind of data mining model), nobody could believe that such a simple set of decision rules could be effective. Fortunes have been made by early adopters since then.

Further reading

Some excellent books on Data Mining:

Dorian Pyle (2003) Business Modeling and Data Mining. ISBN# 155860653-X

Dorian Pyle (1999) Data Preparation for Data Mining. ISBN# 1558605290

Michael Berry & Gordon Linoff (2000) Mastering Data Mining. ISBN# 0471331236

Source Data Mining Models - Tom's Ten Data Tips

Tom Breur: Biographical Sketch

Tom Breur is a consultant out of deep passion for his work.
He can be profoundly analytic, in his passionate quest to drive out the deepest business issues and the nexus point of a business model. It’s all about finding where the least effort will generate the most results.

Once the business challenge becomes clear Tom loves to roll up his sleeves and get his ‘hands dirty’.

Be it data analysis, market research, data mining or database work. Once the hands-on work gets started, his eyes begin to flicker, and he has a tendency to get carried away.

Tom has an academic background in Psychology, an education he took up twice. Initially he majored in Clinical Psychology (1986), years later he went back to college to study Economic Psychology (1996) with an emphasis on quantitative methods.




Source: http://ezinearticles.com/?Data-Mining-Models---Toms-Ten-Data-Tips&id=289130