Wednesday, 20 August 2014

Scrape Data Point Using Python


I am looking to scrape a data point using Python off of the url http://www.cavirtex.com/orderbook .

The data point I am looking to scrape is the lowest bid offer, which at the current moment looks like this:

<tr>
 <td><b>Jan. 19, 2014, 2:37 a.m.</b></td>
 <td><b>0.0775/0.1146</b></td>
 <td><b>860.00000</b></td>
 <td><b>66.65 CAD</b></td>
</tr>

The relevant point being the 860.00 . I am looking to build this into a script which can send me an email to alert me of certain price differentials compared to other exchanges.

I'm quite noobie so if in your explanations you could offer your thought process on why you've done certain things it would be very much appreciated.

Thank you in advance!

Edit: This is what I have so far which will return me the name of the title correctly, I'm having trouble grabbing the table data though.

import urllib2, sys
from bs4 import BeautifulSoup

site= "http://cavirtex.com/orderbook"
hdr = {'User-Agent': 'Mozilla/5.0'}
req = urllib2.Request(site,headers=hdr)
page = urllib2.urlopen(req)
soup = BeautifulSoup(page)
print soup.title



Here is the code for scraping the lowest bid from the 'Buying BTC' table:

from selenium import webdriver

fp = webdriver.FirefoxProfile()
browser = webdriver.Firefox(firefox_profile=fp)
browser.get('http://www.cavirtex.com/orderbook')

lowest_bid = float('inf')
elements = browser.find_elements_by_xpath('//div[@id="orderbook_buy"]/table/tbody/tr/td')

for element in elements:
    text = element.get_attribute('innerHTML').strip('<b>|</b>')
    try:
        bid = float(text)
        if lowest_bid > bid:
            lowest_bid = bid
    except:
        pass

browser.quit()
print lowest_bid

In order to install Selenium for Python on your Windows-PC, run from a command line:

pip install selenium (or pip install selenium --upgrade if you already have it).

If you want the 'Selling BTC' table instead, then change "orderbook_buy" to "orderbook_sell".

If you want the 'Last Trades' table instead, then change "orderbook_buy" to "orderbook_trades".

Note:

If you consider performance critical, then you can implement the data-scraping via URL-Connection instead of Selenium, and have your program running much faster. However, your code will probably end up being a lot "messier", due to the tedious XML parsing that you'll be obliged to apply...

Here is the code for sending the previous output in an email from yourself to yourself:

import smtplib,ssl

def SendMail(username,password,contents):
    server = Connect(username)
    try:
        server.login(username,password)
        server.sendmail(username,username,contents)
    except smtplib.SMTPException,error:
        Print(error)
    Disconnect(server)

def Connect(username):
    serverName = username[username.index("@")+1:username.index(".")]
    while True:
        try:
            server = smtplib.SMTP(serverDict[serverName])
        except smtplib.SMTPException,error:
            Print(error)
            continue
        try:
            server.ehlo()
            if server.has_extn("starttls"):
                server.starttls()
                server.ehlo()
        except (smtplib.SMTPException,ssl.SSLError),error:
            Print(error)
            Disconnect(server)
            continue
        break
    return server

def Disconnect(server):
    try:
        server.quit()
    except smtplib.SMTPException,error:
        Print(error)

serverDict = {
    "gmail"  :"smtp.gmail.com",
    "hotmail":"smtp.live.com",
    "yahoo"  :"smtp.mail.yahoo.com"
}

SendMail("your_username@your_provider.com","your_password",str(lowest_bid))

The above code should work if your email provider is either gmail or hotmail or yahoo.

Please note that depending on your firewall configuration, it may ask your permission upon the first time you try it...



Source: http://stackoverflow.com/questions/21217034/scrape-data-point-using-python

Sunday, 17 August 2014

Data From Web Scraping Using Node.JS Request Is Different From Data Shown In The Browser

Right now, I am doing some simple web scraping, for example get the current train arrival/departure information for one railway station. Here is the example link, http://www.thetrainline.com/Live/arrivals/chester, from this link you can visit the current arrival trains in the chester station.

I am using the node.js request module to do some simple web scraping,

app.get('/railway/arrival', function (req, res, next) {
    console.log("/railway/arrival/  "+req.query["city"]);
    var city = req.query["city"];
    if(typeof city == undefined || city == undefined) { console.log("if it undefined"); city ="liverpool-james-street";}
    getRailwayArrival(city,
       function(err,data){
           res.send(data);
        }
       );
});

function getRailwayArrival(station,callback){
   request({
    uri: "http://www.thetrainline.com/Live/arrivals/"+station,
   }, function(error, response, body) {
      var $ = cheerio.load(body);

      var a = new Array();
      $(".results-contents li a").each(function() {
        var link = $(this);
        //var href = link.attr("href");
        var due = $(this).find('.due').text().replace(/(\r\n|\n|\r|\t)/gm,"");   
        var destination = $(this).find('.destination').text().replace(/(\r\n|\n|\r|\t)/gm,"");
        var on_time = $(this).find('.on-time-yes .on-time').text().replace(/(\r\n|\n|\r|\t)/gm,"");
        if(on_time == undefined)  var on_time_no = $(this).find('.on-time-no').text().replace(/(\r\n|\n|\r|\t)/gm,"");
        var platform = $(this).find('.platform').text().replace(/(\r\n|\n|\r|\t)/gm,"");

        var obj = new Object();
        obj.due = due;obj.destination = destination; obj.on_time = on_time; obj.platform = platform;
        a.push(obj);
console.log("arrival  ".green+due+"  "+destination+"  "+on_time+"  "+platform+"  "+on_time_no);      
    });
    console.log("get station data  "+a.length +"   "+ $(".updated-time").text());
    callback(null,a);

  });
}

The code works by giving me a list of data, however these data are different from the data seen in the browser, though the data come from the same url. I don't know why it is like that. is it because that their server can distinguish the requests sent from server and browser, that if the request is from server, so they sent me the wrong data. How can I overcome this problem ?

thanks in advance.

2 Answers

They must have stored session per click event. Means if u visit that page first time, it will store session and validate that session for next action you perform. Say, u select some value from drop down list. for that click again new value of session is generated that will load data for ur selected combobox value. then u click on show list then that previous session value is validated and you get accurate data.

Now see, if you not catch that session value programatically and not pass as parameter with that request, you will get default loaded data or not get any thing. So, its chalenging for you to chatch that data.Use firebug for help.

Another issue here could be that the generated content occurs through JavaScript run on your machine. jsdom is a module which will provide such content but is not as lightweight.

Cheerio does not execute these scripts and as a result content may not be visible (as you're experiencing). This is an article I read a while back and caused me to have the same discovery, just open the article and search for "jsdom is more powerful" for a quick answer:

Source:http://stackoverflow.com/questions/15785360/data-from-web-scraping-using-node-js-request-is-different-from-data-shown-in-the?rq=1

Sunday, 13 July 2014

Benefits of Outsourcing Data Entry Work in India

Now Days it's a trend to outsource Data Entry Work to reliable service provider who provides excellent output out of their work. Many Companies or Organization prefer to outsource data entry work to offshore location. One of the key reasons why it's become so popular is the fact that the services they provide from highly qualified professionals with cost effective and time bound.

India is well positioned to address global BPO needs. Statistics expose that nearly half of the Fortune 800 companies believe India as a reliable target for offshore outsourcing.

There are lots of benefits of outsourcing data entry work in India

o Reduce capital costs of infrastructure
o Increase productivity and efficiency
o Reduce storage needs
o Latest standard and technology
o Extremely trained workforce
o Quick turn around time with high accuracy
o Strong quality maintained
o Saving human resources
o Focus on your core business.
o Competitive pricing which are low as 40-60% of the prevailing US costs
o Excellent training infrastructure

Data Entry is the procedure of handling and processing over data. There are different forms of data entry like data entry for survey forms, legal services, entry for medical claim forms. Data for keeping track for credit and debit card transactions.

Data entry online services include entering data into websites, e-books, entering image in different format, Data processing and submitting forms, creating database for indexing and mailing for data entered. It also used in insurance claim entry. Procedure of processing of the forms and insurances claims are kept track of data entry services. Scanned image are required for file access and credit and debit card entry.

Data Entry is one of the leading elements for running a business successfully.

Offshore Data Entry has great infrastructure for data entry work projects. We have great equipments, facilities which provide you accurate data entry with high data security. Our data entry services, data entry contract give you quality assurance.

Source:http://ezinearticles.com/?Benefits-of-Outsourcing-Data-Entry-Work-in-India&id=1269756

Wednesday, 9 July 2014

How Web Data Extraction Services Will Save Your Time and Money by Automatic Data Collection

Data scrape is the process of extracting data from web by using software program from proven website only. Extracted data any one can use for any purposes as per the desires in various industries as the web having every important data of the world. We provide best of the web data extracting software. We have the expertise and one of kind knowledge in web data extraction, image scrapping, screen scrapping, email extract services, data mining, web grabbing.

Who can use Data Scraping Services?

Data scraping and extraction services can be used by any organization, company, or any firm who would like to have a data from particular industry, data of targeted customer, particular company, or anything which is available on net like data of email id, website name, search term or anything which is available on web. Most of time a marketing company like to use data scraping and data extraction services to do marketing for a particular product in certain industry and to reach the targeted customer for example if X company like to contact a restaurant of California city, so our software can extract the data of restaurant of California city and a marketing company can use this data to market their restaurant kind of product.

MLM and Network marketing company also use data extraction and data scrapping services to to find a new customer by extracting data of certain prospective customer and can contact customer by telephone, sending a postcard, email marketing, and this way they build their huge network and build large group for their own product and company.

We helped many companies to find particular data as per their need for example.

Web Data Extraction

Web pages are built using text-based mark-up languages (HTML and XHTML), and frequently contain a wealth of useful data in text form. However, most web pages are designed for human end-users and not for ease of automated use. Because of this, tool kits that scrape web content were created. A web scraper is an API to extract data from a web site. We help you to create a kind of API which helps you to scrape data as per your need. We provide quality and affordable web Data Extraction application

Data Collection

Normally, data transfer between programs is accomplished using info structures suited for automated processing by computers, not people. Such interchange formats and protocols are typically rigidly structured, well-documented, easily parsed, and keep ambiguity to a minimum. Very often, these transmissions are not human-readable at all. That's why the key element that distinguishes data scraping from regular parsing is that the output being scraped was intended for display to an end-user.

Email Extractor

A tool which helps you to extract the email ids from any reliable sources automatically that is called a email extractor. It basically services the function of collecting business contacts from various web pages, HTML files, text files or any other format without duplicates email ids.

Screen scrapping

Screen scraping referred to the practice of reading text information from a computer display terminal's screen and collecting visual data from a source, instead of parsing data as in web scraping.

Data Mining Services

Data Mining Services is the process of extracting patterns from information. Datamining is becoming an increasingly important tool to transform the data into information. Any format including MS excels, CSV, HTML and many such formats according to your requirements.

Web spider

A Web spider is a computer program that browses the World Wide Web in a methodical, automated manner or in an orderly fashion. Many sites, in particular search engines, use spidering as a means of providing up-to-date data.

Web Grabber

Web grabber is just a other name of the data scraping or data extraction.

Web Bot

Web Bot is software program that is claimed to be able to predict future events by tracking keywords entered on the Internet. Web bot software is the best program to pull out articles, blog, relevant website content and many such website related data We have worked with many clients for data extracting, data scrapping and data mining they are really happy with our services we provide very quality services and make your work data work very easy and automatic.

Source: http://ezinearticles.com/?How-Web-Data-Extraction-Services-Will-Save-Your-Time-and-Money-by-Automatic-Data-Collection&id=5159023

Monday, 30 June 2014

How to Start an Online Data Backup Business

The data storage industry has evolved into higher levels of sophistication in managing them through secure data centers. Be it maintaining them by mammoth data grids in mine vaults or shared computers like cloud computing, businesses that have started managing third party data have grown bigger and bigger and data management has become a very lucrative industry offering the pedestal for start up software companies to join the bandwagon.

Things that start up service providers should look for in setting up a profitable business are discussed in a very prolific manner. The kind of backup service a start up venture would want to offer depends mainly on the hardware,software and proximity to the client's work site from where the data gets backed up.

Taking these factors into consideration, we as a software vendor to many managed service providers document our experience to help users be enriched with the required knowledge to compete with the myriad businesses in the same league.

First things first, one has to sell the backup service as a package that would include both on-premise and remote backup services. On premise service, as the name suggests, entails data being stored at your client's place using their own data grids. Whereas remote backup service is to have the data loaded into third party hosting like cloud computing servers where client data is transferred through the internet. The latter practice has become very popular in terms of ease of use and cost effectiveness,especially fitting to the likes of start ups who would want to offer backup service for small consumers in their locality,university and small businesses. You can vend your services either to home consumers or people running small businesses depending on your initial hardware costs.

Secondly you need to look for the right software that would suit your data needs. Some recommendations would be to install backup software that helps in smooth transfer of data from your clients computer over to the backup server. It should have all the properties that I mentioned in my earlier articles, so that you do not have to encounter hassles and mess with your client's precious data.

Beware that any fallout on your service would be squarely blamed on you by the client and would adversely hit your relationship with other clientele. Under data exigencies the software used should be able to restore the data that might have got lost in the client's computer and recovered completely as original without even a single byte of data being lost. This aspect should not be ignored as most of the software fail when it comes to restoring the data back. We see to it that the software we build is resilient to huge data transfers and does not fall apart when needed the most.

Lastly, since it is a very niche industry,you have to select your target audience proportionate to the capabilities that would help deliver seamless service even across geographies. Also you need to have a good web portal of your business that elucidates the features of the service and also the pricing for instance whether it is a basic,premium or advanced backup plan. A good support service is required to assist your customers. With these we are very sure that one would definitely succeed and grow the business to greater heights, albeit these steps are not sacrosanct, one can tailor make it to their capabilities and business goals.

Source: http://ezinearticles.com/?How-to-Start-an-Online-Data-Backup-Business&id=3620906

Sunday, 15 June 2014

Data Entry: Why Data Entry Outsourcing?

With the developed technology the world has become a global village, therefore has converted to a single market place. Due to this heavy competition is seen where reduction of overhead for business is possible with the only solution of outsourcing your business to developing countries.

This helps in reducing overhead costs of your business. Companies outsource work in many areas as: call center, software development, CAD, AutoCAD, designing, writing, etc. Out of all these data entry is the most popular, probably because it could be learned easily. Professionals providing services do not only enter your data, but also helps you in managing it for upfront requirements.

These developing services cover several business areas as: online and offline data entry, audio and video entry, image entry, insurance claims entry, numeric data entry, etc. It has become popular because of its impressive benefits associated with it.

Why to outsource Data entry work?

Go for the following benefits associated with it:

Cost effective: Outsourcing your data to enter serves as perfect solution in saving your extra overheads. Outsourcing companies reduce on extra expenditure on resources, receiving equal competency benefits. Outsourcing gives you maximum return on your investment.

Superior Quality: Developing countries having huge human resource are able to provide equal or superior work quality because of its skilled man power. Able to recruit experienced and trained resource are able to provide higher quality work.

Satisfied workforce: As companies get the work done at lower cost compared to developed countries, they pay better to their human capital compared to other work available in their country. This satisfied workforce enthusiastically gives desired results as per client's requirements.

Consistent Data Source in a timely manner: Companies providing outsourcing services to enter data give you consistent and accurate data in a timely manner which can be easily used for the benefits of the organizational needs. Ensuring the efficiency in work flow, this is helpful in saving time.

Developed technology: Though you are outsourcing your entry needs to a developing country, you will find that the technology here you get is efficient, equally upgraded to international standards.

All in one service: Companies providing outsourcing services is also capable of providing related services to its clients in areas such as: online and offline data entry, audio and video entry, image entry, insurance claims, numeric, PDF conversion, image scanning or OCR scanning, image editing, etc.

Report management set-up: Companies providing outsourcing services have a well developed reporting system, with different level heads at communication level. This periodically gives you accurate progress graph of the work assigned.

Thus these services will certainly help you to focus on your core business operations and thus improve your overall productivity.

Offshore Data Entry - We are leading affordable services provider at 60% cutting rates.

Source:http://ezinearticles.com/?Data-Entry:-Why-Data-Entry-Outsourcing?&id=6425948

Monday, 9 June 2014

SEO in Ottawa serves fruitful benefits to a business

Internet marketing is the fastest growing marketing tool around the globe that marketing people are using around the globe because of its wide spread reach. Business nowadays are not only limited till countries to interact with suppliers or buyers around the globe and also display them product catalogue Internet is the best tool. People often use Search engines to satisfy their queries and the results displayed on search engines are what divert the traffic to one’s website hence making it available to all the people around the globe.

These search engines work in a unique way they display results based on keywords submitted to them by the user. Every website has some specific keywords which in turn display the required result and this whole process is known as Search engine optimization (SEO). Business SEO makes sure the keywords submitted to search engines are perfect and relevant to the owner of the website and they also make sure the services provided to the customer are not overly priced.

Internet marketing is the new trend and people are adopting it fast to increase the business and due to internet marketing business are not just confined within countries. Internet marketing Ottawa is set to make all these features available to all the people in Ottawa so that they can benefit from the services. SEO service provider work in a very unique way because the keyword that they choose has to be unique and commonly used as to display the maximum of the result and move the ranking of their product on world wide web. Every website is thoroughly studied and analyzed by SEO provider and hence after the analyzing keywords are defined which are in turn submitted to different search engines which display the result. Every search engines gives different ranking to same website so it might be possible the same website displays on different page on different search engines. Some of the most common search engines are Google, yahoo, bing etc.

SEO provider also makes sure that clients are properly charged and also takes care of the regular updating of the keywords against a decided fee for a fixed interval. Role of SEO service provider is very important because if the keyword is not properly chosen the whole idea of SEO is of no use. Also these service provider can help you in guiding how to go about making a website that would attract more customers choosing the correct domain.

Looking business seo are well known around the globe for providing better service and also they have all the information available online where customer can choose from variety of products read the testimonials pay online and get started with their own SEO of the website. Due to this internet marketing era business have grown manifold and different ways are being found out to maximize the potential of the internet. E commerce industry is one of the largest and rapid growing industries and it’s all possible because of the internet marketing. People can shop learn watch sitting at one place. This is the power of internet.

For further detail about Cheap SEO at BusinessSEO please visit the website.

Source:http://blogs.siliconindia.com/businessseo/Business/SEO-in-Ottawa-serves-fruitful-benefits-to-a-business-bid-cf9206bx48888752.html