Saturday 31 December 2016

Data Mining: Its Description and Uses

Data Mining: Its Description and Uses

Data mining also known as the process of analyzing the KDD which stands for Knowledge Discovery in Databases is a part of statistics and computer science. It is a process which aims to find out many various patterns in enormous sets of relational data.

It uses ways at the fields of machine learning, database systems, artificial intelligence, and statistics. It permits users to examine data from many various perspectives, sort it, and summarize the identified relationships.

In general, the objective of data mining process is to obtain info out of a data set and convert it into a comprehensible outline. Also, it includes the following: data processing, data management and database aspects, visualization, complexity considerations, online updating, inference and model considerations, and interestingness metrics.

On the other hand, the actual data mining assignment is the semi-automatic or automatic exploration of huge quantities of information to extract patterns that are interesting and previously unknown. Such patterns can be the unusual records or the anomaly detection, data records groups or the cluster analysis, and the dependencies or the association rule mining. Usually, this involves utilizing database methods like spatial indexes. Such patters could be perceived as a type of summary of input data, and could be used in further examination or, for example, in predictive analysis and machine learning.

Today, data mining is utilized by different consumer-focused companies like those in the financial, retails, marketing, and communications fields. It permits such companies to find out relationships among the internal aspects like staff skills, price, product positioning, and external aspects like customer information, competition, and economic indicators. Additionally, it allows them to define the effect on corporate profits, sales, and customer satisfaction; and dig into the summary information to be able to see transactional data in detail.

With data mining process, a retailer can make use of point-of-scale customer purchases records to send promotions based on the purchase history of a client. The retailer can improve products and campaigns or promotions that can be appealing to a definite customer group by using mining data from comment cards.

Generally, any of the following relationships are obtained.

1. Associations: Data could be mined to recognize associations.
2. Clusters: Data are sorted based on a rational relationships or consumer preferences.
3. Sequential Patters: Data is mined to expect patterns and trends in behavior.
4. Classes: Data that are stored are utilized to trace data in predetermined segments.

Source : http://ezinearticles.com/?Data-Mining:-Its-Description-and-Uses&id=7252273

Friday 16 December 2016

Data Scrapping

Data Scrapping

People who are involved in business activities might have came across a term Data Scrapping. It is a process in which data or information can be extracted from the Portable Document Format file. They are easy to use tools that can automatically arrange the data that are found in different format in the internet. These advanced tools can collect useful information's according to the need of the user. What the user needs to do is simply enter the key words or phrases and the tool will extract all the related information available from the Portable Document Format file. It is widely used to take information's from the no editable format.

The main advantage of Portable Document Format files are they protect the originality of the document when you convert the data from Word to PDF. The size of the file is reduced by compression algorithems when the file are heavier due to the graphics or the images in the content. A Portable Document Format is independent of any software or hardware for installation. It allows encryption of files which enhances the security of your contents.

Although the Portable Document Format files have many advantages,it too have many other challenges. For example, you want to access a data that you found on the internet and the author encrypted the file preventing you from printing the file, you can easily do the scrapping process. These functions are easily available on the internet and the user can choose according to their needs. Using these programs you can extract the data that u need.

Source : http://ezinearticles.com/?Data-Scrapping&id=4951020

Monday 12 December 2016

Data Extraction - A Guideline to Use Scrapping Tools Effectively

Data Extraction - A Guideline to Use Scrapping Tools Effectively

So many people around the world do not have much knowledge about these scrapping tools. In their views, mining means extracting resources from the earth. In these internet technology days, the new mined resource is data. There are so many data mining software tools are available in the internet to extract specific data from the web. Every company in the world has been dealing with tons of data, managing and converting this data into a useful form is a real hectic work for them. If this right information is not available at the right time a company will lose valuable time to making strategic decisions on this accurate information.

This type of situation will break opportunities in the present competitive market. However, in these situations, the data extraction and data mining tools will help you to take the strategic decisions in right time to reach your goals in this competitive business. There are so many advantages with these tools that you can store customer information in a sequential manner, you can know the operations of your competitors, and also you can figure out your company performance. And it is a critical job to every company to have this information at fingertips when they need this information.

To survive in this competitive business world, this data extraction and data mining are critical in operations of the company. There is a powerful tool called Website scraper used in online digital mining. With this toll, you can filter the data in internet and retrieves the information for specific needs. This scrapping tool is used in various fields and types are numerous. Research, surveillance, and the harvesting of direct marketing leads is just a few ways the website scraper assists professionals in the workplace.

Screen scrapping tool is another tool which useful to extract the data from the web. This is much helpful when you work on the internet to mine data to your local hard disks. It provides a graphical interface allowing you to designate Universal Resource Locator, data elements to be extracted, and scripting logic to traverse pages and work with mined data. You can use this tool as periodical intervals. By using this tool, you can download the database in internet to you spread sheets. The important one in scrapping tools is Data mining software, it will extract the large amount of information from the web, and it will compare that date into a useful format. This tool is used in various sectors of business, especially, for those who are creating leads, budget establishing seeing the competitors charges and analysis the trends in online. With this tool, the information is gathered and immediately uses for your business needs.

Another best scrapping tool is e mailing scrapping tool, this tool crawls the public email addresses from various web sites. You can easily from a large mailing list with this tool. You can use these mailing lists to promote your product through online and proposals sending an offer for related business and many more to do. With this toll, you can find the targeted customers towards your product or potential business parents. This will allows you to expand your business in the online market.

There are so many well established and esteemed organizations are providing these features free of cost as the trial offer to customers. If you want permanent services, you need to pay nominal fees. You can download these services from their valuable web sites also.

Source:http://ezinearticles.com/?Data-Extraction---A-Guideline-to-Use-Scrapping-Tools-Effectively&id=3600918

Tuesday 6 December 2016

Scraping in PDF Files - Improving Accessibility

Scraping in PDF Files - Improving Accessibility

Scraping of data is one procedure where mechanically information is sorted out that is contained on the Net in HTML, PDF and various other documents. It is also about collecting relevant data and saving it in spreadsheets or databases for retrieval purposes. On a majority of sites, text content can be easily accessed in the source code however a good number of business houses are making use of Portable Document Format. This format had been launched by Adobe and documents in this format can be easily viewed on almost any operating system. Some people convert documents from word to PDF when they need sending files over the Net and many convert PDF to word so that they could edit their documents. The best benefit that one gets for making use of it is that documents look a replica of the original and there is no form of disturbance in viewing them as they appear organized and same on almost all operating systems. The downside of the format is that text in such files is converted into a picture or image and then copying and pasting it is not possible any more.

Scraping in this format is a procedure where data is scraped that is available in such files. Most diverse of the tools is needed in order to carry out scraping in a document that is created in this format. You'd find two main forms of PDF files where one is built from a text file and the other firm is where it is built from some image. There is software brought by Adobe itself which can capably do scraping in text based files. For files that are image-based, there is a need to make use of special application for the task.

OCR program is one primary tool to be used for such a matter. Optical Recognition Program is capable in scanning documents for small picture that can be segregated into letters. The pictures are compared with actual letters and given they match well; the letters get copied into one file. These programs are able to do scraping in an apt way in image-based files pretty much aptly however it cannot be said that they are perfect. Once the procedure is done you could search through data so as to find those areas and parts which you had been looking for. More often than not it is difficult to find a utility that can obtain exact data that is needed without proper customization. But if thoroughly checked, you cou

Source: http://ezinearticles.com/?Scraping-in-PDF-Files---Improving-Accessibility&id=6108439

Friday 2 December 2016

Collecting Data With Web Scrapers

Collecting Data With Web Scrapers

There is a large amount of data available only through websites. However, as many people have found out, trying to copy data into a usable database or spreadsheet directly out of a website can be a tiring process. Data entry from internet sources can quickly become cost prohibitive as the required hours add up. Clearly, an automated method for collating information from HTML-based sites can offer huge management cost savings.

Web scrapers are programs that are able to aggregate information from the internet. They are capable of navigating the web, assessing the contents of a site, and then pulling data points and placing them into a structured, working database or spreadsheet. Many companies and services will use programs to web scrape, such as comparing prices, performing online research, or tracking changes to online content.

Let's take a look at how web scrapers can aid data collection and management for a variety of purposes.

Improving On Manual Entry Methods

Using a computer's copy and paste function or simply typing text from a site is extremely inefficient and costly. Web scrapers are able to navigate through a series of websites, make decisions on what is important data, and then copy the info into a structured database, spreadsheet, or other program. Software packages include the ability to record macros by having a user perform a routine once and then have the computer remember and automate those actions. Every user can effectively act as their own programmer to expand the capabilities to process websites. These applications can also interface with databases in order to automatically manage information as it is pulled from a website.

Aggregating Information

There are a number of instances where material stored in websites can be manipulated and stored. For example, a clothing company that is looking to bring their line of apparel to retailers can go online for the contact information of retailers in their area and then present that information to sales personnel to generate leads. Many businesses can perform market research on prices and product availability by analyzing online catalogues.

Data Management

Managing figures and numbers is best done through spreadsheets and databases; however, information on a website formatted with HTML is not readily accessible for such purposes. While websites are excellent for displaying facts and figures, they fall short when they need to be analyzed, sorted, or otherwise manipulated. Ultimately, web scrapers are able to take the output that is intended for display to a person and change it to numbers that can be used by a computer. Furthermore, by automating this process with software applications and macros, entry costs are severely reduced.

This type of data management is also effective at merging different information sources. If a company were to purchase research or statistical information, it could be scraped in order to format the information into a database. This is also highly effective at taking a legacy system's contents and incorporating them into today's systems.

Overall, a web scraper is a cost effective user tool for data manipulation and management.

source: http://ezinearticles.com/?Collecting-Data-With-Web-Scrapers&id=4223877

Tuesday 29 November 2016

Get Started With Scraping – Extracting Simple Tables from PDF Documents

Get Started With Scraping – Extracting Simple Tables from PDF Documents

As anyone who has tried working with “real world” data releases will know, sometimes the only place you can find a particular dataset is as a table locked up in a PDF document, whether embedded in the flow of a document, included as an appendix, or representing a printout from a spreadsheet. Sometimes it can be possible to copy and paste the data out of the table by hand, although for multi-page documents this can be something of a chore. At other times, copy-and-pasting may result in something of a jumbled mess. Whilst there are several applications available that claim to offer reliable table extraction services (some free software,so some open source software, some commercial software), it can be instructive to “View Source” on the PDF document itself to see what might be involved in scraping data from it.

In this post, we’ll look at a simple PDF document to get a feel for what’s involved with scraping a well-behaved table from it. Whilst this won’t turn you into a virtuoso scraper of PDFs, it should give you a few hints about how to get started. If you don’t count yourself as a programmer, it may be worth reading through this tutorial anyway! If nothing else, it may give a feel for the sorts of the thing that are possible when it comes to extracting data from a PDF document.

The computer language I’ll be using to scrape the documents is the Python programming language. If you don’t class yourself as a programmer, don’t worry – you can go a long way copying and pasting other people’s code and then just changing some of the decipherable numbers and letters!

So let’s begin, with a look at a PDF I came across during the recent School of Data data expedition on mapping the garment factories. Much of the source data used in that expedition came via a set of PDF documents detailing the supplier lists of various garment retailers. The image I’ve grabbed below shows one such list, from Varner-Gruppen.

If we look at the table (and looking at the PDF can be a good place to start!) we see that the table is a regular one, with a set of columns separated by white space, and rows that for the majority of cases occupy just a single line.

I’m not sure what the “proper” way of scraping the tabular data from this document is, but here’s the sort approach I’ve arrived at from a combination of copying things I’ve seen, and bit of my own problem solving.

The environment I’ll use to write the scraper is Scraperwiki. Scraperwiki is undergoing something of a relaunch at the moment, so the screenshots may differ a little from what’s there now, but the code should be the same once you get started. To be able to copy – and save – your own scrapers, you’ll need an account; but it’s free, for the moment (though there is likely to soon be a limit on the number of free scrapers you can run…) so there’s no reason not to…;-)

Once you create a new scraper:

you’ll be presented with an editor window, where you can write your scraper code (don’t panic!), along with a status area at the bottom of the screen. This area is used to display log messages when you run your scraper, as well as updates about the pages you’re hoping to scrape that you’ve loaded into the scraper from elsewhere on the web, and details of any data you have popped into the small SQLite database that is associated with the scraper (really, DON’T PANIC!…)

Give your scraper a name, and save it…

To start with, we need to load a couple of programme libraries into the scraper. These libraries provide a lot of the programming tools that do a lot of the heavy lifting for us, and hide much of the nastiness of working with the raw PDF document data.

import scraperwiki
import urllib2, lxml.etree

No, I don’t really know everything these libraries can do either, although I do know where to find the documentation for them… lxm.etree, scraperwiki! (You can also download and run the scraperwiki library in your own Python programmes outside of scraperwiki.com.)

To load the target PDF document into the scraper, we need to tell the scraper where to find it. In this case, the web address/URL of the document is http://cdn.varner.eu/cdn-1ce36b6442a6146/Global/Varner/CSR/Downloads_CSR/Fabrikklister_VarnerGruppen_2013.pdf, so that’s exactly what we’ll use:

url = 'http://cdn.varner.eu/cdn-1ce36b6442a6146/Global/Varner/CSR/Downloads_CSR/Fabrikklister_VarnerGruppen_2013.pdf'

The following three lines will load the file in to the scraper, “parse” the data into an XML document format, which represents the whole PDF in a way that resembles an HTML page (sort of), and then provides us with a link to the “root” of that document.

pdfdata = urllib2.urlopen(url).read()
xmldata = scraperwiki.pdftoxml(pdfdata)
root = lxml.etree.fromstring(xmldata)

If you run this bit of code, you’ll see the PDF document gets loaded in:

Here’s an example of what some of the XML from the PDF we’ve just loaded looks like preview it:

print etree.tostring(root, pretty_print=True)

We can see how many pages there are in the document using the following command:

pages = list(root)
print "There are",len(pages),"pages"

The scraperwiki.pdftoxml library I’m using converts each line of the PDF document to a separate grouped elements. We can iterate through each page, and each element within each page, using the following nested loop:

for page in pages:
  for el in page:

We can take a peak inside the elements using the following print statement within that nested loop:

if el.tag == "text":
  print el.text, el.attrib

Here’s the sort of thing we see from one of the table pages (the actual document has a cover page followed by several tabulated data pages):

Bangladesh {'font': '3', 'width': '62', 'top': '289', 'height': '17', 'left': '73'}
Cutting Edge {'font': '3', 'width': '71', 'top': '289', 'height': '17', 'left': '160'}
1612, South Salna, Salna Bazar {'font': '3', 'width': '165', 'top': '289', 'height': '17', 'left': '425'}
Gazipur {'font': '3', 'width': '44', 'top': '289', 'height': '17', 'left': '907'}
Dhaka Division {'font': '3', 'width': '85', 'top': '289', 'height': '17', 'left': '1059'}
Bangladesh {'font': '3', 'width': '62', 'top': '311', 'height': '17', 'left': '73'}

Looking again the output from each row of the table, we see that there are regular position indicators, particulalry the “top” and “left” coordinates, which correspond to the co-ordinates of where the registration point of each block of text should be placed on the page.

If we imagine the PDF table marked up as follows, we might be able to add some of the co-ordinate values as follows – the blue lines correspond to co-ordinates extracted from the document:

imaginary table lines

We can now construct a small default reasoning hierarchy that describes the contents of each row based on the horizontal (“x-axis”, or “left” co-ordinate) value. For convenience, we pick values that offer a clear separation between the x-co-ordinates defined in the document. In the diagram above, the red lines mark the threshold values I have used to distinguish one column from another:

if int(el.attrib['left']) < 100: print 'Country:', el.text,
elif int(el.attrib['left']) < 250: print 'Factory name:', el.text,
elif int(el.attrib['left']) < 500: print 'Address:', el.text,
elif int(el.attrib['left']) < 1000: print 'City:', el.text,
else:
  print 'Region:', el.text

Take a deep breath and try to follow the logic of it. Hopefully you can see how this works…? The data rows are ordered, stepping through each cell in the table (working left right) for each table row in turn. The repeated if-else statement tries to find the leftmost column into which a text value might fall, based on the value of its “left” attribute. When we find the value of the rightmost column, we print out the data associated with each column in that row.

We’re now in a position to look at running a proper test scrape, but let’s optimise the code slightly first: we know that the data table starts on the second page of the PDF document, so we can ignore the first page when we loop through the pages. As with many programming languages, Python tends to start counting with a 0; to loop through the second page to the final page in the document, we can use this revised loop statement:

for page in pages[1:]:

Here, pages describes a list element with N items, which we can describe explicitly as pages[0:N-1]. Python list indexing counts the first item in the list as item zero, so [1:] defines the sublist from the second item in the list (which has the index value 1 given that we start counting at zero) to the end of the list.

Rather than just printing out the data, what we really want to do is grab hold of it, a row at a time, and add it to a database.

We can use a simple data structure to model each row in a way that identifies which data element was in which column. We initiate this data element in the first cell of a row, and print it out in the last. Here’s some code to do that:

for page in pages[1:]:
  for el in page:
    if el.tag == "text":
      if int(el.attrib['left']) < 100: data = { 'Country': el.text }
      elif int(el.attrib['left']) < 250: data['Factory name'] = el.text
      elif int(el.attrib['left']) < 500: data['Address'] = el.text
      elif int(el.attrib['left']) < 1000: data['City'] = el.text
      else:
        data['Region'] = el.text
        print data

And here’s the sort of thing we get if we run it:

starting to get structured data

That looks nearly there, doesn’t it, although if you peer closely you may notice that sometimes we catch a header row. There are a couple of ways we might be able to ignore the elements in the first, header row of the table on each page.

    We could keep track of the “top” co-ordinate value and ignore the header line based on the value of this attribute.
    We could tack a hacky lazy way out and explicitly ignore any text value that is one of the column header values.

The first is rather more elegant, and would also allow us to automatically label each column and retain it’s semantics, rather than explicitly labelling the columns using out own labels. (Can you see how? If we know we are in the title row based on the “top” co-ordinate value, we can associate the column headings with the “left” coordinate value.) The second approach is a bit more of a blunt instrument, but it does the job…

skiplist=['COUNTRY','FACTORY NAME','ADDRESS','CITY','REGION']
for page in pages[1:]:
  for el in page:
    if el.tag == "text" and el.text not in skiplist:
      if int(el.attrib['left']) < 100: data = { 'Country': el.text }
      elif int(el.attrib['left']) < 250: data['Factory name'] = el.text
      elif int(el.attrib['left']) < 500: data['Address'] = el.text
      elif int(el.attrib['left']) < 1000: data['City'] = el.text
      else:
        data['Region'] = el.text
        print data

At the end of the day, it’s the data we’re after and the aim is not necessarily to produce a reusable, general solution – expedient means occasionally win out! As ever, we have to decide for ourselves the point at which we stop trying to automate everything and consider whether it makes more sense to hard code our observations rather than trying to write scripts to automate or generalise them.

http://xkcd.com/974/ - The General Problem

The final step is to add the data to a database. For example, instead of printing out each data row, we could add the data to the a scraper database table using the command:

scraperwiki.sqlite.save(unique_keys=[], table_name='fabvarn', data=data)

Scraped data preview

Note that the repeated database accesses can slow Scraperwiki down somewhat, so instead we might choose to build up a list of data records, one per row, for each page and them and then add all the companies scraped from a page one page at a time.

If we need to remove a database table, this utility function may help – call it using the name of the table you want to clear…

def dropper(table):
  if table!='':
    try: scraperwiki.sqlite.execute('drop table "'+table+'"')
    except: pass

Here’s another handy utility routine I found somewhere a long time ago (I’ve lost the original reference?) that “flattens” the marked up elements and just returns the textual content of them:

def gettext_with_bi_tags(el):
  res = [ ]
  if el.text:
    res.append(el.text)
  for lel in el:
    res.append("<%s>" % lel.tag)
    res.append(gettext_with_bi_tags(lel))
    res.append("</%s>" % lel.tag)
    if el.tail:
      res.append(el.tail)
  return "".join(res).strip()

If we pass this function something like the string <em>Some text<em> or <em>Some <strong>text</strong></em> it will return Some text.

Having saved the data to the scraper database, we can download it or access it via a SQL API from the scraper homepage:

scrpaed data - db

You can find a copy of the scraper here and a copy of various stages of the code development here.

Finally, it is worth noting that there is a small number of “badly behaved” data rows that split over more than one table row on the PDF.

broken scraper row

Whilst we can handle these within the scraper script, the effort of creating the exception handlers sometimes exceeds the pain associated with identifying the broken rows and fixing the data associated with them by hand.

Summary

This tutorial has shown one way of writing a simple scraper for extracting tabular data from a simply structured PDF document. In much the same way as a sculptor may lock on to a particular idea when working a piece of stone, a scraper writer may find that they lock in to a particular way of parsing data out of a data, and develop a particular set of abstractions and exception handlers as a result. Writing scrapers can be infuriating at times, but may also prove very rewarding in the way that solving any puzzle can be. Compared to copying and pasting data from a PDF by hand, it may also be time well spent!

It is also worth remembering that sometimes it can be quicker to write a scraper that does most of the job, and then finish off the data cleansing or exception handling using another tool, such as OpenRefine or even just a simple text editor. On occasion, it may also make sense to throw the data into a database table as quickly as you can, and then develop code to manage a second pass that takes the raw data out of the database, tidies it up, and then writes it in a cleaner or more structured form into another database table.

Source: http://schoolofdata.org/2013/06/18/get-started-with-scraping-extracting-simple-tables-from-pdf-documents/

Tuesday 15 November 2016

How Xpath Plays Vital Role In Web Scraping Part 2

How Xpath Plays Vital Role In Web Scraping Part 2

Here is a piece of content on  Xpaths which is the follow up of How Xpath Plays Vital Role In Web Scraping

Let’s dive into a real-world example of scraping amazon website for getting information about deals of the day. Deals of the day in amazon can be found at this URL. So navigate to the amazon (deals of the day) in Firefox and find the XPath selectors. Right click on the deal you like and select “Inspect Element with Firebug”:

If you observe the image below keenly, there you can find the source of the image(deal) and the name of the deal in src, alt attribute’s respectively.

So now let’s write a generic XPath which gathers the name and image source of the product(deal).

  //img[@role=”img”]/@src  ## for image source
  //img[@role=”img”]/@alt   ## for product name

In this post, I’ll show you some tips we found valuable when using XPath in the trenches.

If you have an interest in Python and web scraping, you may have already played with the nice requests library to get the content of pages from the Web. Maybe you have toyed around using Scrapy selector or lxml to make the content extraction easier. Well, now I’m going to show you some tips I found valuable when using XPath in the trenches and we are going to use both lxml and Scrapy selector for HTML parsing.

Avoid using expressions which contains(.//text(), ‘search text’) in your XPath conditions. Use contains(., ‘search text’) instead.

Here is why: the expression .//text() yields a collection of text elements — a node-set(collection of nodes).and when a node-set is converted to a string, which happens when it is passed as argument to a string function like contains() or starts-with(), results in the text for the first element only.

from scrapy import Selector
html_code = “””<a href=”#”>Click here to go to the <strong>Next Page</strong></a>”””
sel = Selector(text=html_code)
xp = lambda x: sel.xpath(x).extract()           # Let’s type this only once
print xp(‘//a//text()’)                                       # Take a peek at the node-set
[u’Click here to go to the ‘, u’Next Page’]   # output of above command
print xp(‘string(//a//text())’)                           # convert it to a string
  [u’Click here to go to the ‘]                           # output of the above command

Let’s do the above one by using lxml then you can implement XPath by both lxml or Scrapy selector as XPath expression is same for both methods.

lxml code:

from lxml import html
html_code = “””<a href=”#”>Click here to go to the <strong>Next Page</strong></a>””” # Parse the text into a tree
parsed_body = html.fromstring(html_code)  # Perform xpaths on the tree
print parsed_body(‘//a//text()’)                      # take a peek at the node-set
[u’Click here to go to the ‘, u’Next Page’]   # output
print parsed_body(‘string(//a//text())’)              # convert it to a string
[u’Click here to go to the ‘]                    # output

A node converted to a string, however, puts together the text of itself plus of all its descendants:

>>> xp(‘//a[1]’)  # selects the first a node
[u'<a href=”#”>Click here to go to the <strong>Next Page</strong></a>’]

>>> xp(‘string(//a[1])’)  # converts it to string
[u’Click here to go to the Next Page’]

Beware of the difference between //node[1] and (//node)[1]//node[1] selects all the nodes occurring first under their respective parents and (//node)[1] selects all the nodes in the document, and then gets only the first of them.

from scrapy import Selector

html_code = “””<ul class=”list”>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>

<ul class=”list”>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>”””

sel = Selector(text=html_code)
xp = lambda x: sel.xpath(x).extract()

xp(“//li[1]”) # get all first LI elements under whatever it is its parent

[u'<li>1</li>’, u'<li>4</li>’]

xp(“(//li)[1]”) # get the first LI element in the whole document

[u'<li>1</li>’]

xp(“//ul/li[1]”)  # get all first LI elements under an UL parent

[u'<li>1</li>’, u'<li>4</li>’]

xp(“(//ul/li)[1]”) # get the first LI element under an UL parent in the document

[u'<li>1</li>’]

Also,

//a[starts-with(@href, ‘#’)][1] gets a collection of the local anchors that occur first under their respective parents and (//a[starts-with(@href, ‘#’)])[1] gets the first local anchor in the document.

When selecting by class, be as specific as necessary.

If you want to select elements by a CSS class, the XPath way to do the same job is the rather verbose:

*[contains(concat(‘ ‘, normalize-space(@class), ‘ ‘), ‘ someclass ‘)]

Let’s cook up some examples:

>>> sel = Selector(text='<p class=”content-author”>Someone</p><p class=”content text-wrap”>Some content</p>’)

>>> xp = lambda x: sel.xpath(x).extract()

BAD: because there are multiple classes in the attribute

>>> xp(“//*[@class=’content’]”)

[]

BAD: gets more content than we need

 >>> xp(“//*[contains(@class,’content’)]”)

     [u'<p class=”content-author”>Someone</p>’,
     u'<p class=”content text-wrap”>Some content</p>’]

GOOD:

>>> xp(“//*[contains(concat(‘ ‘, normalize-space(@class), ‘ ‘), ‘ content ‘)]”)
[u'<p class=”content text-wrap”>Some content</p>’]

And many times, you can just use a CSS selector instead, and even combine the two of them if needed:

ALSO GOOD:

>>> sel.css(“.content”).extract()
[u'<p class=”content text-wrap”>Some content</p>’]

>>> sel.css(‘.content’).xpath(‘@class’).extract()
[u’content text-wrap’]

Learn to use all the different axes.

It is handy to know how to use the axes, you can follow through these examples.

In particular, you should note that following and following-sibling are not the same thing, this is a common source of confusion. The same goes for preceding and preceding-sibling, and also ancestor and parent.

Useful trick to get text content

Here is another XPath trick that you may use to get the interesting text contents: 

//*[not(self::script or self::style)]/text()[normalize-space(.)]

This excludes the content from the script and style tags and also skip whitespace-only text nodes.

Tools & Libraries Used:

Firefox
Firefox inspect element with firebug
Scrapy : 1.1.1
Python : 2.7.12
Requests : 2.11.0

 Have questions? Comment below. Please share if you found this helpful.

Source: http://blog.datahut.co/how-xpath-plays-vital-role-in-web-scraping-part-2/

Wednesday 26 October 2016

Outsource Data Mining Services to Offshore Data Entry Company

Outsource Data Mining Services to Offshore Data Entry Company

Companies in India offer complete solution services for all type of data mining services.

Data Mining Services and Web research services offered, help businesses get critical information for their analysis and marketing campaigns. As this process requires professionals with good knowledge in internet research or online research, customers can take advantage of outsourcing their Data Mining, Data extraction and Data Collection services to utilize resources at a very competitive price.

In the time of recession every company is very careful about cost. So companies are now trying to find ways to cut down cost and outsourcing is good option for reducing cost. It is essential for each size of business from small size to large size organization. Data entry is most famous work among all outsourcing work. To meet high quality and precise data entry demands most corporate firms prefer to outsource data entry services to offshore countries like India.

In India there are number of companies which offer high quality data entry work at cheapest rate. Outsourcing data mining work is the crucial requirement of all rapidly growing Companies who want to focus on their core areas and want to control their cost.

Why outsource your data entry requirements?

Easy and fast communication: Flexibility in communication method is provided where they will be ready to talk with you at your convenient time, as per demand of work dedicated resource or whole team will be assigned to drive the project.

Quality with high level of Accuracy: Experienced companies handling a variety of data-entry projects develop whole new type of quality process for maintaining best quality at work.

Turn Around Time: Capability to deliver fast turnaround time as per project requirements to meet up your project deadline, dedicated staff(s) can work 24/7 with high level of accuracy.

Affordable Rate: Services provided at affordable rates in the industry. For minimizing cost, customization of each and every aspect of the system is undertaken for efficiently handling work.

Outsourcing Service Providers are outsourcing companies providing business process outsourcing services specializing in data mining services and data entry services. Team of highly skilled and efficient people, with a singular focus on data processing, data mining and data entry outsourcing services catering to data entry projects of a varied nature and type.

Why outsource data mining services?

360 degree Data Processing Operations
Free Pilots Before You Hire
Years of Data Entry and Processing Experience
Domain Expertise in Multiple Industries
Best Outsourcing Prices in Industry
Highly Scalable Business Infrastructure
24X7 Round The Clock Services

The expertise management and teams have delivered millions of processed data and records to customers from USA, Canada, UK and other European Countries and Australia.

Outsourcing companies specialize in data entry operations and guarantee highest quality & on time delivery at the least expensive prices.

Herat Patel, CEO at 3Alpha Dataentry Services possess over 15+ years of experience in providing data related services outsourced to India.

Visit our Facebook Data Entry profile for comments & reviews.

Our services helps to convert any kind of  hard copy sources, our data mining services helps to collect business contacts, customer contact, product specifications etc., from different web sources. We promise to deliver the best quality work and help you excel in your business by focusing on your core business activities. Outsource data mining services to India and take the advantage of outsourcing and save cost.

Source: http://ezinearticles.com/?Outsource-Data-Mining-Services-to-Offshore-Data-Entry-Company&id=4027029

Saturday 15 October 2016

What are the ethics of web scraping?

What are the ethics of web scraping?

Someone recently asked: "Is web scraping an ethical concept?" I believe that web scraping is absolutely an ethical concept. Web scraping (or screen scraping) is a mechanism to have a computer read a website. There is absolutely no technical difference between an automated computer viewing a website and a human-driven computer viewing a website. Furthermore, if done correctly, scraping can provide many benefits to all involved.

There are a bunch of great uses for web scraping. First, services like Instapaper, which allow saving content for reading on the go, use screen scraping to save a copy of the website to your phone. Second, services like Mint.com, an app which tells you where and how you are spending your money, uses screen scraping to access your bank's website (all with your permission). This is useful because banks do not provide many ways for programmers to access your financial data, even if you want them to. By getting access to your data, programmers can provide really interesting visualizations and insight into your spending habits, which can help you save money.

That said, web scraping can veer into unethical territory. This can take the form of reading websites much quicker than a human could, which can cause difficulty for the servers to handle it. This can cause degraded performance in the website. Malicious hackers use this tactic in what’s known as a "Denial of Service" attack.

Another aspect of unethical web scraping comes in what you do with that data. Some people will scrape the contents of a website and post it as their own, in effect stealing this content. This is a big no-no for the same reasons that taking someone else's book and putting your name on it is a bad idea. Intellectual property, copyright and trademark laws still apply on the internet and your legal recourse is much the same. People engaging in web scraping should make every effort to comply with the stated terms of service for a website. Even when in compliance with those terms, you should take special care in ensuring your activity doesn't affect other users of a website.

One of the downsides to screen scraping is it can be a brittle process. Minor changes to the backing website can often leave a scraper completely broken. Herein lies the mechanism for prevention: making changes to the structure of the code of your website can wreak havoc on a screen scraper's ability to extract information. Periodically making changes that are invisible to the user but affect the content of the code being returned is the most effective mechanism to thwart screen scrapers. That said, this is only a set-back. Authors of screen scrapers can always update them and, as there is no technical difference between a computer-backed browser and a human-backed browser, there's no way to 100% prevent access.

Going forward, I expect screen scraping to increase. One of the main reasons for screen scraping is that the underlying website doesn't have a way for programmers to get access to the data they want. As the number of programmers (and the need for programmers) increases over time, so too will the need for data sources. It is unreasonable to expect every company to dedicate the resources to build a programmer-friendly access point. Screen scraping puts the onus of data extraction on the programmer, not the company with the data, which can work out well for all involved.

Source: https://quickleft.com/blog/is-web-scraping-ethical/

Friday 23 September 2016

How to use Web Content Extractor(WCE) as Email Scraper?

How to use Web Content Extractor(WCE) as Email Scraper?

Web Content Extractor is a great web scraping software developed by Newprosoft Team. The software has easy to use project wizard to create a scraping configuration and scrape data from websites.

One day I came to see the Visual Email Extractor which is also product of Newprosoft and similar to Web Content Extractor but it’s primary use is to scrape email addresses by crawling websites you feed to the scraper. I had noticed that with the little modification in Web Content Extractor project configuration you can use it same as Visual Email Extractor to extract email addresses.

In this post I will show you what configuration makes the Web Content Extractor to extract email addresses. I still recommend Visual Email Extractor as it has lot more features then extracting email using WCE.

Here are the configuration that makes WCE to Extract Emails.

Step 1 : Open Web Content Extractor and Create New Project and Click on Next.

Step 2:  Under Crawling Rules -> Advanced Rules Tab do the following settings

Crawling Level 1 Settings

Follow Links if link text equals:
*contact*; *feedback*; *support*; *about*

for 'Follow Links if link text equals' text box enter following values:
contact; feedback; support; about

for 'Do not Follow links if URL contains' text box enter following values:

google.; yahoo.; bing; msn.; altavista.; myspace.com; youtube.com; googleusercontent.com; =http; .jpg; .gif; .png; .bmp; .exe; .zip; .pdf;

Set 'Maximum Crawling Deapth' to 2

set 'Crawling Order' to Deapth First Crawling

Tick mark below below check boxes:

->Follow all internal links

  Crawling Level 2  Settings

set 'Follow links if link text equals' to below value

*contact*; *feedback*; *support*; *about*

set 'Follow links if url contains' text box to below value

contact; feedback; support; about

set 'DO NOT follow links if url contains' text box to below value

=http

Step 3 After doing above settings now click on Next  -> in Extraction Pattern window -> Click on Define ->  in Web Page Address (URL) give any URL where email is given.  and click on  + sign right of Date Fields to define scraping pattern.

Now inside HTML Structure selects HTML check box or Body check box which means for each page it will take whole page content to parse data.

Now last settings to extract emails from page using regular expression based email extraction function.  Open Predefined Script window and select ‘Extract_Email_Addresses‘ and click on OK. and if you have used page that contains email then in Script Result’ you will be able to see the harvested email.

Hope this will help you to use your Web Content Extractor as a Email Scraper.. Share your view in comment.

Source: http://webdata-scraping.com/use-web-content-extractor-as-email-scraper/

Wednesday 14 September 2016

Run Code Template – New Feature Added to Fminer Web Scraping Tool

Run Code Template – New Feature Added to Fminer Web Scraping Tool

Fminer is one of the powerful web scraping software, I already given brief of all the Fminer features in previous post. In this post I am going to introduce one of the interesting feature of fminer which is Run Code Template that is recently added to Fminer, this feature is similar to “Fminer Run Code” action but it’s different in a way you can use it. The Run Code Action you can use inside the data scraping flow and python code get executed when scraper start running.

While Run Code Templates are the saved python code snippets that you can run on the data tables after scraping completes. Assume if you get white space in scraped data then you can easily trim this left and right spaces by just executing “strip_column” template, see the code of that template below.

'''Strip all data of a column in data table
Remove the blank of data in the head and the tail.
'''

tabName = '[%table1|data table%]'
colName = '[%table1.column1|table column for strip%]'

tab = tables[tabName]
for i, row in enumerate(tab):
    row[colName] = row[colName].strip()   
    tab.edit_row(i, row)

This template comes with Fminer and few other template like “merge_tables_with_same_columns”.  Below are the steps how you can execute template python code on scraped data.

Step 1: Click on second icon from right that says “Run Code” under the Data section

Step 2: One popup will appear, you need to click on “Templates” icon and choose the template you want to execute and then click on Ok.

Step 3: Now the window will appear for configuration that will ask you to choose the table and column under that table on which you want to execute the code. Now click on Ok again.

Step 4: Now you can see the code of that template, now you can click on execute icon and script will start running, based on number of records it will take time to finish execution.

In many web scraping projects I found this template code very handy for cleaning data and making life easy. Templates are stored at following path so you can create your own template with customized code.

C:\Program Files (x86)\FMiner\templates

I have created one template which I use to remove HTML code that comes while scraping badly organized HTML pages. Below is the code of template for stripping html:

'''Strip HTML will remove all html tags of a column in data table.
'''
import re
tabName = '[%table1|data table%]'
colName = '[%table1.column1|table column for substring%]'
colNew = '[%table1.column1|table column to add new data%]'
tab = tables[tabName]
for i, row in enumerate(tab):
    cleanr =re.compile('<.*?>')
    cleantext = re.sub(cleanr,'', row[colName])
    row[colNew] = cleantext 
    tab.edit_row(i, row)

Stay connected as I am going to post more code templates that will make your web scraping life easy and manipulate data on fly.

Source: http://webdata-scraping.com/run-code-template-new-feature-added-fminer-web-scraping-tool/

Saturday 3 September 2016

How Web Scraping for Brand Monitoring is used in Retail Sector

How Web Scraping for Brand Monitoring is used in Retail Sector

Structured or unstructured, business data always plays an instrumental part in driving growth, development, and innovation for your dream venture. Irrespective of industrial sectors or verticals, big data, seems to be of paramount significance for every business or enterprise.

The unsurpassed popularity and increasing importance of big data gave birth to the concept of web scraping, thus enhancing growth opportunities for startups. Large or small, every business establishment will now achieve successful website monitoring and tracking.
How web scraping serves your branding need?

Web scraping helps in extracting unorganized data and ordering it into organized and manageable formats. So if your brand is being talked about in multiple ways (on social media, on expert forums, in comments etc.), you can set the scraping tool algorithm to fetch only data that contains reference about the brand. As an outcome, marketers and business owners around the brand can gauge brand sentiment and tweak their launch marketing campaign to enhance visibility.

Look around and you will discover numerous web scraping solutions ranging from manual to fully automated systems. From Reputation Tracking to Website monitoring, your web scraper can help create amazing insights from seemingly random bits of data (both in structured as well as unstructured format).
Using web scraping

The concept of web scraping revolutionizes the use of big data for business. With its availability across sectors, retailers are on cloud nine. Here’s how the retail market is utilizing the power of Web Scraping for brand monitoring.

Determining pricing strategy

The retail market is filled with competition. Whether it is products or pricing strategies, every retailer competes hard to stay ahead of the growth curve. Web scraping techniques will help you crawl price comparison sites’ pricing data, product descriptions, as well as images to receive data for comparison, affiliation, or analytics.

As a result, retailers will have the opportunity to trade their products at competitive prices, thus increasing profit margins by a whopping 10%.

Tracking online presence

Current trends in ecommerce herald the need for a strong online presence. Web scraping takes cue from this particular aspect, thus scraping reviews and profiles on websites. By providing you a crystal clear picture of product performance, customer behavior, and interactions, web scraping will help you achieve Online Brand Intelligence and monitoring.
Detection of fraudulent reviews

Present-day purchasers have this unique habit of referring to reviews, before finalizing their purchase decisions. Web scraping helps in the identification of opinion-spamming, thus figuring out fake reviews. It will further extend support in detecting, reviewing, streamlining, or blocking reviews, according to your business needs.
Online reputation management

Web data scraping helps in figuring out avenues to take your ORM objectives forward. With the help of the scraped data, you learn about both the impactful as well as vulnerable areas for online reputation management. You will have the web crawler identifying demographic opinions such as age group, gender, sentiments, and GEO location.

Social media analytics

Since social media happens to be one of the most crucial factors for retailers, it will be imperative to Scrape Social Media websites and extract data from Twitter. The web scraping technology will help you watch your brand in Social Media along with fetching Data for social media analytics. With social media channels such as Twitter monitoring services, you will strengthen your firm’s’ branding even more than before.
Advantages of BM

As a business, you might want to monitor your brand in social media to gain deep insights about your brand’s popularity and the current consumer behavior. Brand monitoring companies will watch your brand in social media and come up with crucial data for social media analytics. This process has immense benefits for your business, these are summarized over here –

Locate Infringers

Leading brands often face the challenge thrown by infringers. When brand monitoring companies keep a close look at products available in the market, there is less probability of a copyright infringement. The biggest infringement happens in the packaging, naming and presentation of products. With constant monitoring and legal support provided by the Trademark Law, businesses could remain protected from unethical competitors and illicit business practices.

Manage Consumer Reaction and Competitor’s Challenges

A good business keeps a check on the current consumer sentiment in the targeted demographic and positively manages the same in the interest of their brand. The feedback from your consumers could be affirmative or negative but if you have a hold on the social media channels, web platforms and forums, you, as a brand will be able to propagate trust at all times.

When competitor brands indulge in backbiting or false publicity about your brand, you can easily tame their negative comments by throwing in a positive image in front of your target audience. So, brand monitoring and its active implementation do help in positive image building and management for businesses.
Why Web scraping for BM?

Web scraping for brand monitoring gives you a second pair of eyes to look at your brand as a general consumer. Considering the flowing consumer sentiment in the market during a specific business season, you could correct or simply innovate better ways to mold the target audience in your brand’s favor. Through a systematic approach towards online brand intelligence and monitoring, future business strategies and possible brand responses could be designed, keeping your business actively prepared for both types of scenarios.

For effective web scraping, businesses extract data from Twitter that helps them understand ‘what’s trending’ in their business domain. They also come closer to reality in terms of brand perception, user interaction and brand visibility in the notions of their clientele. Web scraping professionals or companies scrape social media websites to gather relevant data related to your brand or your competitor’s that has the potential to affect your growth as a business. Management and organization of this data is done to extract out significant and reference building facts. Future strategy for your brand is designed by brand monitoring professionals keeping in mind the facts accumulated through web scraping. The data obtained through web scraping helps in –

Knowing the actual brand potential,
Expanding brand coverage,
Devising brand penetration,
Analyzing scope and possibilities for a brand and
Design thoughtful and insightful brand strategies.

In simple words, web scraping provides a business enough base of information that could be used to devise future plans and to make suggestive changes in the current business strategy.

Advantages of Web scraping for BM

Web scraping has made things seamless for businesses involved in managing their brands and active brand monitoring. There is no doubt, that web scraping for brand monitoring comes with immense benefits, some of these are –

Improved customer insight

When you have in hand and factual knowledge about your consumer base through social media channels, you are in a strong position to portray your positive image as a brand. With more realistic data on your hands, you could develop strategies more effectively and make realistic goals for your brand’s improvement. Social media insights also allows marketers to create highly targeted and custom marketing messages – thus leading to better likelihood of sales conversion.

Monitoring your Competition

Web scraping helps you realize where your brand stands in the market among the competition. The actual penetration of your brand in the targeted segment helps in getting a clear picture of your present business scenario. Through careful removal of competition in your concerned business category, you could strengthen your brand image.

Staying Informed

When your brand monitoring team is keeping track of all social media channels, it becomes easier for you to stay informed about latest comments about your business on sites like Facebook, Twitter and social forums etc. You could have deep knowledge about the consumer behavior related to your brand and your competitors on these web destinations.

Improved Consumer Satisfaction and Sales

Reputation tracking done through web scraping helps in generating planned response at times of crisis. It also mends the communication gap between consumer and the brand, hence improving the consumer satisfaction. This automatically translates into trust building and brand loyalty improving your brand’s sales.

To sign off

By granting opportunities to monitor your social media data, web scraping is undoubtedly helping retail businesses take a significant step towards perfect branding. If you are one of the key players in this sector, there’s reason for celebration ahead!

Source: https://www.promptcloud.com/blog/How-Web-Scraping-for-Brand-Monitoring-is-used-in-Retail-Sector

Saturday 27 August 2016

Why Healthcare Companies should look towards Web Scraping

Why Healthcare Companies should look towards Web Scraping

The internet is a massive storehouse of information which is available in the form of text, media and other formats. To be competitive in this modern world, most businesses need access to this storehouse of information. But, all this information is not freely accessible as several websites do not allow you to save the data. This is where the process of Web Scraping comes in handy.

Web scraping is not new—it has been widely used by financial organizations, for detecting fraud; by marketers, for marketing and cross-selling; and by manufacturers for maintenance scheduling and quality control. Web scraping has endless uses for business and personal users. Every business or individual can have his or her own particular need for collecting data. You might want to access data belonging to a particular category from several websites. The different websites belonging to the particular category display information in non-uniform formats. Even if you are surfing a single website, you may not be able to access all the data at one place.

The data may be distributed across multiple pages under various heads. In a market that is vast and evolving rapidly, strategic decision-making demands accurate and thorough data to be analyzed, and on a periodic basis. The process of web scraping can help you mine data from several websites and store it in a single place so that it becomes convenient for you to a alyze the data and deliver results.

In the context of healthcare, web scraping is gaining foothold gradually but qualitatively. Several factors have led to the use of web scraping in healthcare. The voluminous amount of data produced by healthcare industry is too complex to be analyzed by traditional techniques. Web scraping along with data extraction can improve decision-making by determining trends and patterns in huge amounts of intricate data. Such intensive analyses are becoming progressively vital owing to financial pressures that have increased the need for healthcare organizations to arrive at conclusions based on the analysis of financial and clinical data. Furthermore, increasing cases of medical insurance fraud and abuse are encouraging healthcare insurers to resort to web scraping and data extraction techniques.

Healthcare is no longer a sector relying solely on person to person interaction. Healthcare has gone digital in its own way and different stakeholders of this industry such as doctors, nurses, patients and pharmacists are upping their ante technologically to remain in sync with the changing times. In the existing setup, where all choices are data-centric, web scraping in healthcare can impact lives, educate people, and create awareness. As people no more depend only on doctors and pharmacists, web scraping in healthcare can improve lives by offering rational solutions.

To be successful in the healthcare sector, it is important to come up with ways to gather and present information in innovative and informative ways to patients and customers. Web scraping offers a plethora of solutions for the healthcare industry. With web scraping and data extraction solutions, healthcare companies can monitor and gather information as well as track how their healthcare product is being received, used and implemented in different locales. It offers a safer and comprehensive access to data allowing healthcare experts to take the right decisions which ultimately lead to better clinical experience for the patients.

Web scraping not only gives healthcare professionals access to enterprise-wide information but also simplifies the process of data conversion for predictive analysis and reports. Analyzing user reviews in terms of precautions and symptoms for diseases that are incurable till date and are still undergoing medical research for effective treatments, can mitigate the fear in people. Data analysis can be based on data available with patients and is one way of creating awareness among people.

Hence, web scraping can increase the significance of data collection and help doctors make sense of the raw data. With web scraping and data extraction techniques, healthcare insurers can reduce the attempts of frauds, healthcare organizations can focus on better customer relationship management decisions, doctors can identify effective cure and best practices, and patients can get more affordable and better healthcare services.

Web scraping applications in healthcare can have remarkable utility and potential. However, the triumph of web scraping and data extraction techniques in healthcare sector depends on the accessibility to clean healthcare data. For this, it is imperative that the healthcare industry think about how data can be better recorded, stored, primed, and scraped. For instance, healthcare sector can consider standardizing clinical vocabulary and allow sharing of data across organizations to heighten the benefits from healthcare web scraping practices.

Healthcare sector is one of the top sectors where data is multiplying exponentially with time and requires a planned and structured storage of data. Continuous web scraping and data extraction is necessary to gain useful insights for renewing health insurance policies periodically as well as offer affordable and better public health solutions. Web scraping and data extraction together can process the mammoth mounds of healthcare data and transform it into information useful for decision making.

To reduce the gap between various components of healthcare sector-patients, doctors, pharmacies and hospitals, healthcare organizations and websites will have to tap the technology to collect data in all formats and present in a usable form. The healthcare sector needs to overcome the lag in implementing effective web scraping and data extraction techniques as well as intensify their pace of technology adoption. Web scraping can contribute enormously to the healthcare industry and facilitate organizations to methodically collect data and process it to identify inadequacies and best practices that improve patient care and reduce costs.

Source: https://www.promptcloud.com/blog/why-health-care-companies-should-use-web-scraping

Tuesday 16 August 2016

Business Intelligence & Data Warehousing in a Business Perspective

Business Intelligence & Data Warehousing in a Business Perspective

Business Intelligence


Business Intelligence has become a very important activity in the business arena irrespective of the domain due to the fact that managers need to analyze comprehensively in order to face the challenges.

Data sourcing, data analysing, extracting the correct information for a given criteria, assessing the risks and finally supporting the decision making process are the main components of BI.

In a business perspective, core stakeholders need to be well aware of all the above stages and be crystal clear on expectations. The person, who is being assigned with the role of Business Analyst (BA) for the BI initiative either from the BI solution providers' side or the company itself, needs to take the full responsibility on assuring that all the above steps are correctly being carried out, in a way that it would ultimately give the business the expected leverage. The management, who will be the users of the BI solution, and the business stakeholders, need to communicate with the BA correctly and elaborately on their expectations and help him throughout the process.

Data sourcing is an initial yet crucial step that would have a direct impact on the system where extracting information from multiple sources of data has to be carried out. The data may be on text documents such as memos, reports, email messages, and it may be on the formats such as photographs, images, sounds, and they can be on more computer oriented sources like databases, formatted tables, web pages and URL lists. The key to data sourcing is to obtain the information in electronic form. Therefore, typically scanners, digital cameras, database queries, web searches, computer file access etc, would play significant roles. In a business perspective, emphasis should be placed on the identification of the correct relevant data sources, the granularity of the data to be extracted, possibility of data being extracted from identified sources and the confirmation that only correct and accurate data is extracted and passed on to the data analysis stage of the BI process.

Business oriented stake holders guided by the BA need to put in lot of thought during the analyzing stage as well, which is the second phase. Synthesizing useful knowledge from collections of data should be done in an analytical way using the in-depth business knowledge whilst estimating current trends, integrating and summarizing disparate information, validating models of understanding, and predicting missing information or future trends. This process of data analysis is also called data mining or knowledge discovery. Probability theory, statistical analysis methods, operational research and artificial intelligence are the tools to be used within this stage. It is not expected that business oriented stake holders (including the BA) are experts of all the above theoretical concepts and application methodologies, but they need to be able to guide the relevant resources in order to achieve the ultimate expectations of BI, which they know best.

Identifying relevant criteria, conditions and parameters of report generation is solely based on business requirements, which need to be well communicated by the users and correctly captured by the BA. Ultimately, correct decision support will be facilitated through the BI initiative and it aims to provide warnings on important events, such as takeovers, market changes, and poor staff performance, so that preventative steps could be taken. It seeks to help analyze and make better business decisions, to improve sales or customer satisfaction or staff morale. It presents the information that manager's need, as and when they need it.

In a business sense, BI should go several steps forward bypassing the mere conventional reporting, which should explain "what has happened?" through baseline metrics. The value addition will be higher if it can produce descriptive metrics, which will explain "why has it happened?" and the value added to the business will be much higher if predictive metrics could be provided to explain "what will happen?" Therefore, when providing a BI solution, it is important to think in these additional value adding lines.

Data warehousing

In the context of BI, data warehousing (DW) is also a critical resource to be implemented to maximize the effectiveness of the BI process. BI and DW are two terminologies that go in line. It has come to a level where a true BI system is ineffective without a powerful DW, in order to understand the reality behind this statement, it's important to have an insight in to what DW really is.

A data warehouse is one large data store for the business in concern which has integrated, time variant, non volatile collection of data in support of management's decision making process. It will mainly have transactional data which would facilitate effective querying, analyzing and report generation, which in turn would give the management the required level of information for the decision making.

The reasons to have BI together with DW

At this point, it should be made clear why a BI tool is more effective with a powerful DW. To query, analyze and generate worthy reports, the systems should have information available. Importantly, transactional information such as sales data, human resources data etc. are available normally in different applications of the enterprise, which would obviously be physically held in different databases. Therefore, data is not at one particular place, hence making it very difficult to generate intelligent information.

The level of reports expected today, are not merely independent for each department, but managers today want to analyze data and relationships across the enterprise so that their BI process is effective. Therefore, having data coming from all the sources to one location in the form of a data warehouse is crucial for the success of the BI initiative. In a business viewpoint, this message should be passed and sold to the managements of enterprises so that they understand the value of the investment. Once invested, its gains could be achieved over several years, in turn marking a high ROI.

Investment costs for a DW in the short term may look quite high, but it's important to re-iterate that the gains are much higher and it will span over many years to come. It also reduces future development cost since with the DW any requested report or view could be easily facilitated. However, it is important to find the right business sponsor for the project. He or she needs to communicate regularly with executives to ensure that they understand the value of what's being built. Business sponsors need to be decisive, take an enterprise-wide perspective and have the authority to enforce their decisions.

Process

Implementation of a DW itself overlaps with some phases of the above explained BI process and it's important to note that in a process standpoint, DW falls in to the first few phases of the entire BI initiative. Gaining highly valuable information out of DW is the latter part of the BI process. This can be done in many ways. DW can be used as the data repository of application servers that run decision support systems, management Information Systems, Expert systems etc., through them, intelligent information could be achieved.

But one of the latest strategies is to build cubes out of the DW and allow users to analyze data in multiple dimensions, and also provide with powerful analytical supporting such as drill down information in to granular levels. Cube is a concept that is different to the traditional relational 2-dimensional tabular view, and it has multiple dimensions, allowing a manager to analyze data based on multiple factors, and not just two factors. On the other hand, it allows the user to select whatever the dimension he wish to choose for analyzing purposes and not be limited by one fixed view of data, which is called as slice & dice in DW terminology.

BI for a serious enterprise is not just a phase of a computerization process, but it is one of the major strategies behind the entire organizational drivers. Therefore management should sit down and build up a BI strategy for the company and identify the information they require in each business direction within the enterprise. Given this, BA needs to analyze the organizational data sources in order to build up the most effective DW which would help the strategized BI process.

High level Ideas on Implementation

At the heart of the data warehousing process is the extract, transform, and load (ETL) process. Implementation of this merely is a technical concern but it's a business concern to make sure it is designed in such a way that it ultimately helps to satisfy the business requirements. This process is responsible for connecting to and extracting data from one or more transactional systems (source systems), transforming it according to the business rules defined through the business objectives, and loading it into the all important data model. It is at this point where data quality should be gained. Of the many responsibilities of the data warehouse, the ETL process represents a significant portion of all the moving parts of the warehousing process.

Creation of a powerful DW depends on the correctness of data modeling, which is the responsibility of the database architect of the project, but BA needs to play a pivotal role providing him with correct data sources, data requirements and most importantly business dimensions. Business Dimensional modeling is a special method used for DW projects and this normally should be carried out by the BA and from there onwards technical experts should take up the work. Dimensions are perspectives specific to a business that could be used for analysis purposes. As an example, for a sales database, the dimensions could include Product, Time, Store, etc. Obviously these dimensions differ from one business to another and hence for each DW initiative those dimensions should be correctly identified and that could be very well done by a person who has experience in the DW domain and understands the business as well, making it apparent that DW BA is the person responsible.

Each of the identified dimensions would be turned in to a dimension table at the implementation phase, and the objective of the above explained ETL process is to fill up these dimension tables, which in turn will be taken to the level of the DW after performing some more database activities based on a strong underlying data model. Implementation details are not important for a business stakeholder but being aware of high level process to this level is important so that they are also on the same pitch as that of the developers and can confirm that developers are actually doing what they are supposed to do and would ultimately deliver what they are supposed to deliver.

Security is also vital in this regard, since this entire effort deals with highly sensitive information and identification of access right to specific people to specific information should be correctly identified and captured at the requirements analysis stage.

Advantages

There are so many advantages of BI system. More presentation of analytics directly to the customer or supply chain partner will be possible. Customer scores, customer campaigns and new product bundles can all be produced from analytic structures resulting in high customer retention and creation of unique products. More collaboration within information can be achieved from effective BI. Rather than middle managers getting great reports and making their own areas look good, information will be conveyed into other functions and rapidly shared to create collaborative decisions increasing the efficiency and accuracy. The return on human capital will be greatly increased.

Managers at all levels will save their time on data analysis, and hence saving money for the enterprise, as the time of managers is equal to money in a financial perspective. Since powerful BI would enable monitoring internal processes of the enterprises more closely and allow making them more efficient, the overall success of the organization would automatically grow. All these would help to derive a high ROI on BI together with a strong DW. It is a common experience to notice very high ROI figures on such implementations, and it is also important to note that there are many non-measurable gains whilst we consider most of the measurable gains for the ROI calculation. However, at a stage where it is intended to take the management buy-in for the BI initiative, it's important to convert all the non measurable gains in to monitory values as much as possible, for example, saving of managers time can be converted in to a monitory value using his compensation.

The author has knowledge in both Business and IT. Started career as a Software Engineer and moved to work in the business analysis area of a premier US based software company.

Source: http://ezinearticles.com/?Business-Intelligence-and-Data-Warehousing-in-a-Business-Perspective&id=35640

Monday 8 August 2016

Web Scraping Best Practices

Web Scraping Best Practices

Extracting data from the World Wide Web has several challenges as more webmasters are working day and night to lower cases of scraping and crawling of their data in order to survive in the competitive world. There are various other problems you may face when web scraping and most of them can be avoided by adapting and implementing certain web scraping best practices as discussed in this article.

Have knowledge of the scraping tools

Acquiring adequate knowledge of hurdles that may be encountered during web scraping, you will be able to have a smooth web scraping experience and be on the safe side of the law. Conduct a thorough research on the types of tools you will use for scraping and crawling. Firsthand knowledge on these tools will help you find the data you need without being blocked.

Proper proxy software that acts as the middle party works well when you know how to work around HTTP and HTML protocols. Use tools that can change crawling patterns, URLs and data retrieved even when you are crawling on one domain. This will help you abide to the rules and regulations that come with web scraping activities and escaping any legal issues.
Conduct your scraping activities during off-peak hours

You may opt to extract data during times that less people have access for instance over the weekends, during late night hours, public holidays among others. Visiting a website on several instances to retrieve the same type of data is a waste of bandwidth. It is always advisable to download the entire site content to your computer and thereafter you can access it whenever need arises.
Hide your scrapping activities

There is a thin line between ethical and unethical crawling hence you should completely evade being on the top user list of a particular website. Cover up your track as best as you can by making use of proxy IPs to avoid any legal problems. You may also use multiple IP addresses or VPN services to conceal your scrapping activities and lower chances of landing on a website’s blacklist.

Website owners today are very protective of their data and any other information existing under their unique url. Be keen when going through the terms and conditions indicated by websites as they may consider crawling as an infringement of their privacy. Simple etiquette goes a long way. Your web scraping efforts will be fruitful if the site owner supports the idea of sharing data.
Keep record of your activities

Web scraping involves large amount of data.Due to this you may not always remember each and every piece of information you have acquired, gathering statistics will help you monitor your activities.
Load data in phases

Web scraping demands a lot of patience from you when using the crawlers to get needed information. Take the process in a slow manner by loading data one piece at a time. Several parallel request to the same domain can crush the entire site or retrace the scrapping attempts back to your local machine.

Loading data small bits will save you the hustle of scrapping afresh in case that your activity has been interrupted because you will have already stored part of the data required. You can reduce the loading data on an individual domain through various techniques such as caching pages that you have scrapped to escape redundancy occurrences. Use auto throttling mechanisms to increase the amount of traffic to the website and pause for breaks between requests to prevent getting banned.
Conclusion

Through these few mentioned web scraping best practices you will be able to work around website and gather the data required as per clients’ request without major hurdles along the way. The ultimate goal of every web scraper is to be able to access vital information and at the same time remain on the good side of the law.

Source: http://nocodewebscraping.com/web-scraping-best-practices/

Wednesday 3 August 2016

Three Common Methods For Web Data Extraction

Three Common Methods For Web Data Extraction


Probably the most common technique used traditionally to extract data from web pages this is to cook up some regular expressions that match the pieces you want (e.g., URL's and link titles). Our screen-scraper software actually started out as an application written in Perl for this very reason. In addition to regular expressions, you might also use some code written in something like Java or Active Server Pages to parse out larger chunks of text. Using raw regular expressions to pull out the data can be a little intimidating to the uninitiated, and can get a bit messy when a script contains a lot of them. At the same time, if you're already familiar with regular expressions, and your scraping project is relatively small, they can be a great solution.

Other techniques for getting the data out can get very sophisticated as algorithms that make use of artificial intelligence and such are applied to the page. Some programs will actually analyze the semantic content of an HTML page, then intelligently pull out the pieces that are of interest. Still other approaches deal with developing "ontologies", or hierarchical vocabularies intended to represent the content domain.

There are a number of companies (including our own) that offer commercial applications specifically intended to do screen-scraping. The applications vary quite a bit, but for medium to large-sized projects they're often a good solution. Each one will have its own learning curve, so you should plan on taking time to learn the ins and outs of a new application. Especially if you plan on doing a fair amount of screen-scraping it's probably a good idea to at least shop around for a screen-scraping application, as it will likely save you time and money in the long run.

So what's the best approach to data extraction? It really depends on what your needs are, and what resources you have at your disposal. Here are some of the pros and cons of the various approaches, as well as suggestions on when you might use each one:

Raw regular expressions and code

Advantages:

- If you're already familiar with regular expressions and at least one programming language, this can be a quick solution.

- Regular expressions allow for a fair amount of "fuzziness" in the matching such that minor changes to the content won't break them.

- You likely don't need to learn any new languages or tools (again, assuming you're already familiar with regular expressions and a programming language).

- Regular expressions are supported in almost all modern programming languages. Heck, even VBScript has a regular expression engine. It's also nice because the various regular expression implementations don't vary too significantly in their syntax.

Disadvantages:

- They can be complex for those that don't have a lot of experience with them. Learning regular expressions isn't like going from Perl to Java. It's more like going from Perl to XSLT, where you have to wrap your mind around a completely different way of viewing the problem.

- They're often confusing to analyze. Take a look through some of the regular expressions people have created to match something as simple as an email address and you'll see what I mean.

- If the content you're trying to match changes (e.g., they change the web page by adding a new "font" tag) you'll likely need to update your regular expressions to account for the change.

- The data discovery portion of the process (traversing various web pages to get to the page containing the data you want) will still need to be handled, and can get fairly complex if you need to deal with cookies and such.

When to use this approach: You'll most likely use straight regular expressions in screen-scraping when you have a small job you want to get done quickly. Especially if you already know regular expressions, there's no sense in getting into other tools if all you need to do is pull some news headlines off of a site.

Ontologies and artificial intelligence

Advantages:

- You create it once and it can more or less extract the data from any page within the content domain you're targeting.

- The data model is generally built in. For example, if you're extracting data about cars from web sites the extraction engine already knows what the make, model, and price are, so it can easily map them to existing data structures (e.g., insert the data into the correct locations in your database).

- There is relatively little long-term maintenance required. As web sites change you likely will need to do very little to your extraction engine in order to account for the changes.

Disadvantages:

- It's relatively complex to create and work with such an engine. The level of expertise required to even understand an extraction engine that uses artificial intelligence and ontologies is much higher than what is required to deal with regular expressions.

- These types of engines are expensive to build. There are commercial offerings that will give you the basis for doing this type of data extraction, but you still need to configure them to work with the specific content domain you're targeting.

- You still have to deal with the data discovery portion of the process, which may not fit as well with this approach (meaning you may have to create an entirely separate engine to handle data discovery). Data discovery is the process of crawling web sites such that you arrive at the pages where you want to extract data.

When to use this approach: Typically you'll only get into ontologies and artificial intelligence when you're planning on extracting information from a very large number of sources. It also makes sense to do this when the data you're trying to extract is in a very unstructured format (e.g., newspaper classified ads). In cases where the data is very structured (meaning there are clear labels identifying the various data fields), it may make more sense to go with regular expressions or a screen-scraping application.

Screen-scraping software

Advantages:

- Abstracts most of the complicated stuff away. You can do some pretty sophisticated things in most screen-scraping applications without knowing anything about regular expressions, HTTP, or cookies.

- Dramatically reduces the amount of time required to set up a site to be scraped. Once you learn a particular screen-scraping application the amount of time it requires to scrape sites vs. other methods is significantly lowered.

- Support from a commercial company. If you run into trouble while using a commercial screen-scraping application, chances are there are support forums and help lines where you can get assistance.

Disadvantages:

- The learning curve. Each screen-scraping application has its own way of going about things. This may imply learning a new scripting language in addition to familiarizing yourself with how the core application works.

- A potential cost. Most ready-to-go screen-scraping applications are commercial, so you'll likely be paying in dollars as well as time for this solution.

- A proprietary approach. Any time you use a proprietary application to solve a computing problem (and proprietary is obviously a matter of degree) you're locking yourself into using that approach. This may or may not be a big deal, but you should at least consider how well the application you're using will integrate with other software applications you currently have. For example, once the screen-scraping application has extracted the data how easy is it for you to get to that data from your own code?

When to use this approach: Screen-scraping applications vary widely in their ease-of-use, price, and suitability to tackle a broad range of scenarios. Chances are, though, that if you don't mind paying a bit, you can save yourself a significant amount of time by using one. If you're doing a quick scrape of a single page you can use just about any language with regular expressions. If you want to extract data from hundreds of web sites that are all formatted differently you're probably better off investing in a complex system that uses ontologies and/or artificial intelligence. For just about everything else, though, you may want to consider investing in an application specifically designed for screen-scraping.

As an aside, I thought I should also mention a recent project we've been involved with that has actually required a hybrid approach of two of the aforementioned methods. We're currently working on a project that deals with extracting newspaper classified ads. The data in classifieds is about as unstructured as you can get. For example, in a real estate ad the term "number of bedrooms" can be written about 25 different ways. The data extraction portion of the process is one that lends itself well to an ontologies-based approach, which is what we've done. However, we still had to handle the data discovery portion. We decided to use screen-scraper for that, and it's handling it just great. The basic process is that screen-scraper traverses the various pages of the site, pulling out raw chunks of data that constitute the classified ads. These ads then get passed to code we've written that uses ontologies in order to extract out the individual pieces we're after. Once the data has been extracted we then insert it into a database.

Source: http://ezinearticles.com/?Three-Common-Methods-For-Web-Data-Extraction&id=165416

Saturday 30 July 2016

Tips for scraping business directories

Tips for scraping business directories

Are you looking to scrape business directories to generate leads?

Here are a few tips for scraping business directories.

Web scraping is not rocket science. But there are good and bad and worst ways of doing it.

Generating sales qualified leads is always a headache. The old school ways are to buy a list from sites like Data.com. But they are quite expensive.

Scraping business directories can help generate sales qualified leads. The following tips can help you scrape data from business directories efficiently.

1) Choose a good framework to write the web scrapers. This can help save a lot of time and trouble. Python Scrapy is our favourite, but there are other non-pythonic frameworks too.

2) The business directories might be having anti-scraping mechanisms. You have to use IP rotating services to do the scrape. Using IP rotating services, crawl with multiple changing IP addresses which can cover your tracks.

3) Some sites really don’t want you to scrape and they will block the bot. In these cases, you may need to disguise your web scraper as a human being. Browser automation tools like selenium can help you do this.

4) Web sites will update their data quite often. The scraper bot should be able to update the data according to the changes. This is a hard task and you need professional services to do that.

One of the easiest ways to generate leads is to scrape from business directories and use enrich them. We made Leadintel for lead research and enrichment.

Source: http://blog.datahut.co/tips-for-scraping-business-directories/

Monday 11 July 2016

Extract Data from Multiple Web Pages into Excel using import.io

In this tutorial, i will show you how to extract data from multiple web pages of a website or blog and save the extracted data into Excel spreadsheet for further processing.There are various methods and tools to do that but I found them complicated and I prefer to use import.io to accomplish the task.Import.io doesn’t require you to have programming skills.The platform is quite powerful,user-friendly with a lot of support online and above all FREE to use.

You can use the online version of their data extraction software or a desktop application.The online version will be covered in this tutorial.

Let us get started.

Step 1:Find a web page you want to extract data from.
You can extract data such as prices, images, authors’ names, addresses,dates etc

Step 2:Enter the URL for that web page into the text box here and click “Extract data”.

Then click  “Extract data” Import.io will transform the web page into data in seconds.Data such as authors,images,posts published dates and posts title will be pulled from the web page as shown in the image below.

Import.io extracted only 40 posts or articles from the first page of the blog!.
If you visit bongo5.com you will notice that the web page is having a total of 600+ pages at the time of writing this article and each page has 40 posts or articles on it as can be shown by the image below.
Next step will show you how to extract data from multiple pages of the web page into excel.

Step 3:Extract Data from Multiple Web Pages into Excel

Using the import.io online tool you can extract data from 20 web pages maximum.Go to the bottom right corner of the import.io online tool page and click “Download CSV” to save the extracted data from those 20 pages into Excel.
Note:Using the import.io desktop application you can extract an unlimited number of pages and pin point only the data you want to extract.Check out this tutorial on how to use the desktop application.
Once you click “Download CSV” the following pop up window will appear.You can specify the number of pages you want to get data from up to a maximum of 20 pages then click “Go!”
You will need to Sign up for a free account to download that data as a CSV, or save it as an API.If you save it as an API you can go back to the API later to extract new data if the web page is updated without the need to repeat the steps we have done so far.Also, you can use the API for integration into other platforms.
Below image shows 20 rows out of 800 rows of data extracted from the 20 pages of the web page.

Conclusion

The online tool doesn’t offer much flexibility than the desktop application.For example, you can not extract more than 20 pages and you can not pin point the type of data you want to extract.For a more advanced tutorial on how to use the desktop application, you can check out this tutorial I created earlier.

Source URL : http://nocodewebscraping.com/extract-multiple-web-pages-data-into-excel/