God’s Word: The Bible

NewImage

God’s Word: The Bible

 

Question:Why do we have a Bible? 

 

Answer:Simple answer – so we can “know” Him, but not just by the WORD of someone else, but by the very breath of God. That’s what the Bible is – it’s GOD’S WORDS to us!

 

History in all it’s truth – though having much “fact” bends over time and becomes corrupt. It’s kind of like the game “Broken Telephone”. I tell you something secretly, and you tell someone else secretly, and the further the message is passed on, the further it is corrupted, that is, the message changes. And for that very reason – I believe, God gave us HIS WORD in the form of a Bible – to be PERFECT and WITHSTAND corruption. Imagine God’s Word, or the truth of salvation resting in the hands of men to be passed on from generation to generation; I think that might result in some serious corruption and abuse. Isn’t it wonderful to know, that if someone says something to you, that you can pick up a Bible and find the answer for yourself? Now that’s wonderful!

 

Many have tried to disprove the Bible, it’s truth, its reliability and they have every time failed, or made an argument that lacks context or understanding for the Bible’s truth. The Bible has in fact proved history, and not just proved it – but made predictions about history, and those things have come to pass. There are about 2500 prophecies in scripture, of which 2000 have reliably come to pass, with 500 yet to be fulfilled.

 

The Bible is Perfect!

Now that’s a statement, yes that’s right, the Bible is PERFECT! Without error, unquestionable, without corruption. How can I say that? Through basic logic; why would God leave behind His Word, that has error’s in it? Consider judgement day, a man about to be cast into hell, and there he claims “..but God, your Bible said this and this; and so I followed it, and now you want to cast me into hell?”. God could never do that! By God’s very own nature, we know Him to be HOLY, PERFECT and JUST (else He would not be God); and thus HIS WORD, His instructions to us, have to be PERFECT as HE Himself is perfect. How can you trust or bet your life on something that is “unreliable”? You can’t!

 

“In the beginning was Word, and the Word was with God, and the Word was God” Jhn 1:1

“And the Word was made flesh and dwelt among us”.  – John 1:14

Wonderful! Here we see Jesus Christ being likened or equated to the “WORD”, that is, the WORD of GOD, which is our Bibles.  (Past)

 

“And there are three that bear witness in heaven, the Father, the Word, and the Holy Ghost; and these three are one”  – 1 John 5:7

Here we see the Holy Trinity, the God Head, and again we Jesus being likened or called the “WORD” of God. Another reference to our Bibles. (Present)

 

“And he was clothed with a vesture dipped in blood; and his name is called the WORD of GOD” – Revelation 19:13  (Future – Jesus at His second coming in the context)

This is the third time, that Jesus Christ is directly linked to the WORD of GOD (our Bibles), in three tenses; past, present and in future! So if we say our Bible is corrupt, in actual fact, we are saying; SO IS JESUS! But that could never be true and so our Bible must be PERFECT and without error! The Bible friend, is God’s WORD, and we can trust it, for there is nothing on this earth as pure and as reliable!


Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

God’s Desire: Relationship

God’s Desire: Relationship

 

Question: As a child of God, a believer, what does God desire from me?

 

Answer:

Firstly above ALL things, God desires to have “fellowship” with you. That is God desires to relate to you, and you to Him. Simplistically, He desires to have a heart, that loves Him, seeks Him, thirsts for Him and pursues Him. All the way back in Genesis, we see that when God created “Adam and Eve”, He would come down to the earth to meet with them (Genesis 3:8), to speak to them, to fellowship with them and to express His love for them.

 

 

Relationship

 

Individual and Different:

Some would seek to “define” this relationship a child of God is to have with His Father, but that is impossible to do. God through His Word has given us some commands and principals by which we are to live, as found in the Bible, but how each of us are to “relate” to Jesus is different. Consider you and I as “artists” called to paint the same object – each presented with their own set of tools – paint, brushes and a canvas. Our personality, our perspective and our past may influence the painting completely – from the form and shape, to the array of colors used and the time taken to complete it. You may use less of this, and more of that, and I none at all – though the same tools, same object, yet a different end result. So too your relationship with Jesus is different and relational; to how God made you and what He desires from you. These basic tools for our relationship with Jesus are – (1) talking too Him (Prayer),  (2) learning more about Him (Bible) and (3) loving those around us, particularly fellow believers (Church). How we use these, in what measure, over what time, and frequency is based on our “heart” for Him, and who we are as individuals. 

 

How to have a “relationship” with Jesus?

I believe you know that answer as you have existing “relationships” with your parents, spouse, child or co-workers. But perhaps a great way to see this, is in that initial “courting” phase of a couple; it starts off by them desiring one another, then deciding to pursue the other person; then learning more about each other and seeking to spend time in each other’s company. This is the foundation of any relationship of intimacy, and the same is applicable in our “relationship” with Jesus

 

“And to know the love of Christ, which passeth knowledge, that ye might be filled with all the fulness of God” (Ephesians 3:19). God above all, desires that you have a relationship with Him, because where there is no relationship, how can there be an expression of love, care or interest. To know Christ’s love, is to be IN LOVE with CHRIST.  The more time you spend with Him, the more you will love Him. This is a child of God’s first FOCUS, not “good deeds or works” – but a “relationship” with JESUS. As presented in the diagram above, “good works” follow a “good relationship” with HIM. Bless you!

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

God’s Promise: Assurance of Salvation

Heaven

God’s Promise: Assurance

~ To a Christian who is saved or born again

 

Question: So you say you are “saved” through faith in Jesus Christ? But here is a question for you, if you sinned today and died there after would you go to heaven or hell? 

 

Scenario:

Here is a scenario to help you understand the question. Consider a man, named Fred who is “saved”, as you are, and one day got into a really bad situation. The situation got so out of control that he ended up killing a man. Imagine just for a moment, before Fred could confess his sin, before he could repent, he himself died, and was taken before the LORD JESUS, to be judged. Would the LORD JESUS CHRIST let Fred into heaven; or cast him into hell?

 

Truth:

The answer is simple – Fred would enter into heaven. But how can that be so, after he did one of the worst sins imaginable, he took the life of another? Yes Fred is guilty, and he committed a sin, but friend, no one get’s to heaven by their own merit, in fact no one who trusts in their “good works” (charity, prayer, reading the bible) can ever enter into heaven. 

 

The qualification for “heaven” is being without sin, having broken no law of GOD in your entire life, that is – “PERFECT” and “SINLESS”. If you had but broken the law once or committed the smallest of sins, then you stand guilty before God. If a man raped your wife, your sister, or daughter, and stood before a judge, and that judge let the rapist go; would that judge be a fair and righteous judge? Of course not, so why do we expect any different, or any less from GOD who is the HIGHEST and MOST RIGHTEOUS of all judges.

 

So yes Fred is guilty, but can Fred do anything to earn favor with God? Can Fred give God something to let him escape from the wrong he has done? No, because if God did have to accept something from Fred, that would be bribery, and again this cannot be God, and so nothing you do, no matter how good, pure or holy, can be sufficient payment for your sin.

 

That is why, God the Judge, sent His only Son to this earth to die, and be that “ransom” that payment for your sin, and for all that you have done wrong in breaking his law. And so now because the “merit” of your entrance into heaven is not you, but Jesus Christ, it doesn’t matter what you did, done or will do – you enter into heaven by the payment of JESUS, by HIM laying HIS life down FOR YOU, by HIM being that payment.So Fred enters into heaven, because He believed Jesus Christ by “faith” – that JESUS died and rose again the third day, and that the work of JESUS was payment enough for his (Fred) sins. Thus we are PROMISED HEAVEN, by WHO JESUS IS and WHAT JESUS DID, and our belief in HIM.

 

  1. Rom 3:23 – “For ALL have sinned, and come short of the glory of God” (All guilty)
  2. Rom 10:9 “That if thou shalt confess with thy mouth the LORD Jesus, and shalt believe in thine heart that God hath raise him from the dead, thou shalt be SAVED 
  3. Eph 2:8-9“For by GRACE are ye SAVED through FAITH; and that not of yourselves: it is the GIFT of God. NOT of WORKS, lest any man should boast.”
  4. 1 John 5:11-14“And this is the record, that God hath given to us eternal life, and this life is in his Son. He that hath the Son hath life; and he that hath not the Son of God hath not life. These things have I written unto you that believe on the name of the Son of God; that ye may know that ye have eternal life, and that ye may believe on the name of the Son of God. And this is the confidencethat we have in him…” (Also 1 John 4:15-17)
Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Why should I use SASS?

 Problem:

Being a web developer one often hits that momentous stumbling block, of though being able to knit code together amazingly, that the “code’s face”, the actual UI is not quite what as “beautiful” as it’s internal structure. Perhaps a reason for this is not a lack of creativity, but rather a syntax that is “sour, leaving a bitter taste” in ones mouth – and that of CSS. Sometimes it’s not that the developer lacks “design skills”, but that he or she fails to come to terms with a language that’s “crude and difficult to read”. 

It’s kind of like an “artist” who has a palette with “two colors”, and the result of every painting is a boring stale end-result that is repeated over and over. However, if the “artist” is then informed, that he/she has an array of colors, as they find or choose to be necessary; then what can be created is truly marvelous!

My point – CSS for new developers can take a while to understand, grasp or even stomach, and in steps SASS (Syntactically Awesome Style Sheets). This then, is that introduction to something sweet that can help make your “web development” experience more pleasurable and less painful (easy to maintain, and less repeatable).

 

SASS

What Is SASS?

SASS friend, is simply a framework or rather a set of tools for allowing developers to leverage CSS in a manner that is more logical, and as “Rails developers like to say”, more DRY (Don’t Repeat Yourself).

Why use SASS?

Why use SASS? Now a Google will return lots of results and I mean there are so many frameworks out there, unless referred to by a colleague etc; you almost pass it by, thinking it’s just another “web” technology among the myriad. So to address that I would like to just cover 3 of Top “PRO’s” of SASS, that can bring immediate improvement to your “development time and experience” and perhaps persuade you to use it.

Variables

In developing any web site, I like to stick to 3 colors at a maximum to predominantly decide the look and feel or the UI. Often times, I find myself hunting down shades of one primary color, like blue, light-blue etc (or rather their HEX Values).

The beauty of SASS, is that we have Variables, yes, actual “Variables”, so you can do something like:

 $gray-Dark: #474546;

So now, when I need to reference that, let’s say for a 


header {
 background-color: $gray-Dark;
}

footer {
 margin-top: 30px;
 padding-top: 5px;
 border-top: 1px solid $gray-Dark;
 background-color: $gray-Light;
}

The power behind this of course, is now you have one reference point for changing a color as opposed to rippling through multiple CSS or a large CSS to change the color for all accompanying tags. Also a great plus, for quick “mockups”.

But let’s say, however, I wanted to make my footer slightly lighter as a variant of Gray. I could define a new variable, as such:


$gray-Light: lighten($gray-Dark, 20%);

footer {
 margin-top: 30px;
 padding-top: 5px;
 border-top: 1px solid $gray-Dark;
 background-color: $gray-Light;
}

There are a myriad of other functions, and you should check that out (like “darken”, “lightness” etc).

Nesting:

Now traditionally with CSS you would do the follow to NEST;


#header {
 background-color: $gray-Dark;
}

#header h1 {
 float: left;
}

With SASS, ‘nesting’ is much sweeter; we can NEST directly inside the target (class).


#header {
 background-color: $gray-Dark;

h1 {
 float: left;
 }

}

Functions:

Would you believe it, yes, your own functions. Now I cannot express enough the power behind this, but let’s use an example to give you some idea.


#header {
 background-color: $gray-Dark;
 border-radius: 10px;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;

h1 {
 float: left;
 }
}

#nav-left {
 padding: 5px 12px;
 margin: 10px 0;
 border-radius: 10px;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;
}

#footer {
 border: solid 1px $gray-Dark
 border-radius: 10px;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;
}

Now as you can see the border-radius is repeated 3 times. A change to one would require me to meticulously make changes to all three. But that’s a bit cumbersome not to mention extra code, extending the size of my file, and decreasing readability. With SASS, I can instead rip out this ‘CSS’ and create a seperate function for this which I can address in all 3 places.

At the head of my file, where my variables are declared; we add in our Function, or as SASS calls it, MIXIN.


@mixin <name> {

// CODE TO REPEAT
}

@mixin rounded-corners {
 border-radius: 10px;
 -moz-border-radius: 10px;
 -webkit-border-radius: 10px;
}

And it’s implementation like this:


#header {
 background-color: $gray-Dark;
 @include rounded-corners

h1 {
 float: left;
 }
}

#nav-left {
 padding: 5px 12px;
 margin: 10px 0;
 @include rounded-corners
}

#footer {
 border: solid 1px $gray-Dark
 @include rounded-corners
}

But let’s say, the rounded corners are different for #nav-left – instead of 10px for the border-radius it should be 8px. How can SASS help us?

Well a “function” (mixin) is not a true function unless we can also provide “parameters” or “arguments”. So let’s modify our MIXIN a little to support custom radii.

That is:


@mixin rounded-corners($radius) {
 border-radius: $radius;
 -moz-border-radius: $radius;
 -webkit-border-radius: $radius;
}

But before we implement, how about a default, in places were the MIXIN is used, but no radius is specified;


@mixin rounded-corners($radius: 8px) {
 border-radius: $radius;
 -moz-border-radius: $radius;
 -webkit-border-radius: $radius;
}

Beautiful isn’t it, but let’s look at our implementation, which if you being any sort of developer should already have in your mind:


#header {
 background-color: $gray-Dark;
 @include rounded-corners(10px);

h1 {
 float: left;
 }
}

#nav-left {
 padding: 5px 12px;
 margin: 10px 0;
 @include rounded-corners(8px);
}

#footer {
 border: solid 1px $gray-Dark
 @include rounded-corners(10px);
}

But the programmability doesn’t end there, and again, so not to overload you with information, but to give you an understanding of it’s power; SASS also supports Conditional States (if, else if, else); as well as “For” loops and “For Each”.

Conclusion:

This is just the tip of the iceberg of SASS, and if you would like to learn more, you can visit the following links:

  1. SASS Website
  2. SASS Functions
  3. Beginner Tutorial on SASS
  4. Advanced Tutorial on SASS
Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

The King Shall Come

1 Thess 4:13-18

Across the earth voices cry, 

oh when will precious justice reign? 

When will He, the God of all eternity, 

dwell with me.

 

The heathen mock and rage,

 spit and curse that Holy Name,

Yet Christian martyrs still His Name Avail.

Stay the storm brothers, till that blessed coming reign.

 

Oh the anguish, trials and sorrows our hearts oft cry,

But there is hope, there is hope I say.

For the King of Glory shall come again, 

Look up High, His splendour draweth nigh!

 

For on a horse, justice rides,

For He gathers against the fallen tides,

And in a swift voice and powerful cry,

Shall he vanquish the prince of demonic lie.

 

Down from the heavens and through the clouds He’ll descend,

Bearing all His saintly brethren friend,

And as we shout, exclaim and proclaim that Holy Name,

Our King would have surely come again.

 

And on that day joy and peace will come our way,

For in His presence we shall live day by day.

Yes I say,

Our Lord is coming back soon

 

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Understanding Election: Part 1

1. Introduction

Good Read

Calvinism is quite simply a distraction to churches or even the Christian walk. I’ve personally spent hours trying to come to an understanding of what it is and how to defend against it. Sadly, in looking at different books, in speaking to even “mighty men” of God, they to themselves struggle to explain it, or rather succinctly for understanding. That being said, I found it then necessary to write a document, to the intent and purposes that I first myself would use it to remember and rekindle the thoughts and avenues I went through to come to grips with a topic that everyone has an opinion on and a different approach.

What the reader must bare in mind, that the topic is not meant for carnal Christians or babes in Christ, if it is, then it is likely that you are seeking head knowledge, instead of “getting God”. Further added, sometimes in trying your best to understand something, you will fail time and time again, and it will appear all to complex, and that’s simply because, a certain maturing by the LORD is required for you to get there. Imagine trying to explain a car engine to a 2 year old, not quite! But as he get’s older, maybe 10 you explain cars and their basic function. As he grows older, you teach him to change a tyre, perhaps do some basic maintenance. As he applies “theory” (faith) and practice, the result is COMPREHENSION. I hope you get the point.

Now let’s get down to understanding the nature of the beast. One thing before I do, Calvinism debated outside of “scripture” is folly – to further elaborate, logic by nature though sound and reliable is sometimes flawed. Say for example, there are 3 kids in a room, and I leave 3 chocolates on a table and walk out, instructing the 3 kids not to eat them. Upon returning I find that the three chocolates have now disappeared, surely logic would dictate that each child in the room was responsible for a missing chocolate. Ah, not true, there could have just been one rebellious child who he himself took all 3 chocolates, refusing to share and ate them all. There are many areas of failed logic, for example, fallacy of division – if a car is blue, and then the engine must be blue. Fallacy of cause and effect – when the rooster crows, the sun rises. Therefore the sun rises because the rooster crows. I make this point to show you, that the only authority is scripture, the only logic (if I can call it that) that is sound, is from the Word of God, and thus our arguments either within ourselves or outside(with others), should be on verses in the bible and not philosophical. A basic assumption, but one all too easily made.

In this part. we will look at Unconditional Election, not following the exact order, but dealing perhaps with the one that’s most prevalent.

2. Unconditional Election

Get One Now :)

The most important lesson you can learn is that in your King James Bible, a word read is often times not it’s meaning. No, I am not being cryptic, nor am I emphasizing a need for the Greek, but what I am stating, is that often times words to us, take “societal” or “traditional” slants, and this is predominantly the case with the word “Election”. Immediately because of Calvinism, the word “Election” means – those ‘chosen’ by God either by His foreknowledge or by His own “random” desire.

However an assessment of the word through scripture, mentioned 6 times in the New Testament, reveals, a “choosing” by God according to a purpose, and speaks nothing about “salvation”. Not only that but every time it is used, in relation to the church, it is always speaking about a “saved believer”. 

For example:

Romans 9:11 (For the children being not yet born, neither having done any good or evil, that the purpose of God according to election might stand, not of works, but of him that calleth;)

God chose Jacob over Esau to bring forth the birth of Israel as a nation, as God’s elect people, that is, the people to reveal the glory of God and to show forth His purposes, according to His will. It is important to remember three things, 

  1. When the statement is made in scripture, by way of timing, as this can help explain the verse far better and give it context. Paying attention to this can give the “Election” (choosing) context for when it happened, as opposed to always assuming it happened before the foundation of the world.
  2. That when “Election” is used in relation to Israel, it has nothing to do with salvation, but God choosing to bless Israel, and reveal more of Himself through a group of people.
  3. If you do go through the six verses (Rom 9:11, 11:5, 11:7, 11:28, 1 Thes 1:4, 2 Peter 1:10), you will find election within an election. Take Rom 11:5, God chose Israel to be His special people (Election 1), but not all believed by faith, and some went straight to hell. However in seeing the hearts of men, God elected (chose) a remnant who by their own “faith” would believe on Him (Election 2). This is so critical to understand, as it shows that “Election” has zero, zilch, nothing to do with “salvation”.

A better explanation sticking to the point of “Election” meaning choosing unto a purpose of God and for God; look at the following example:

Acts 9:15 But the Lord said unto him, Go thy way: for he is a chosen vessel unto me, to bear my name before the Gentiles, and kings, and the children of Israel: 

There is no reference to salvation here, only the purposes to which Paul was called, to be a minister and servant of the Lord Jesus Christ, to the furtherance of the gospel and more importantly his apostleship.

If you struggle to believe these two words are interchangeable, look up the following references; John 6:70, Luke 6:13 (not the timing as mentioned in point (a) above), John 15:16, Mark 13:20,Luke 10:42, Acts 1:24, John 15:19, Acts 6:5,Acts 13:17.

One more important point to deal with and that is of Ephesians 1:4-6, this is a verse used a pivotal form of defense for Calvinists, yet they refuse to just read the plain historical grammatical King James Bible, 

Ephesians 1:4 According as he hath chosen us in him before the foundation of the world, that we should be holy and without blame before him in love:

Ephesians 1:5 Having predestinated us unto the adoption of children by Jesus Christ to himself, according to the good pleasure of his will.

Ephesians 1:6 To the praise of the glory of his grace, wherein he hath made us accepted in the beloved.

Let me rewrite that with some added emphasis:

Ephesians 1:4 According as he hath chosen us IN HIM before the foundation of the world, that WE SHOULD be holy and without blame before him in love:

Ephesians 1:5 Having predestinated us unto the ADOPTION of children BY JESUS CHRIST to himself, according to the good pleasure of his will.

Ephesians 1:6 To the PRAISE of the glory of his grace, wherein he hath made us accepted in the beloved.

Two main themes in these verses, how are people chosen and the purpose of their being “chosen”.

 How are people “elected” or chosen then? Simple – by believing IN Christ, by being IN Christ (Ephesians 1:1-3; pay attention to the wording “in Christ”) and thus are they chosen. They are not set apart before the foundation of the world, no rather, sinners who call upon are the name of the Lord by their own free will, are now “predestinated” and “chosen” of God, to be “adopted” into His family, and destined for Glory (glorification). This is God’s elect – and their purpose to PRAISE Him! Again, he is talking to “saved believers” and not the unsaved.

Remember, “foreknowledge” always precedes “election” or “pre-destination”. God knew the paths that man would take by His foreknowledge of them all, and made a way through Jesus Christ that they might have salvation. He made a way, not chose a certain of the populous to be saved; what kind of God would He be then? We are not robots who are saved and sanctified in eternity; nor is God playing a game with those He did not “elect” (in the traditional sense of the word); where they are offered the gospel but can never accept it!!!! Again, what kind of God would He be?

Hope that helps. Bless you.



Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

HTML Scraper with Ruby

Introduction:

 

Great Gem

Being a .NET Developer by trade, I’ve become increasingly interested in Ruby. Being a C# developer for years, one finds one self often drifting to the “dark side” of open-source to play, learn and experience.

And on one such night, I decide how about test driving Ruby – and this little project. In South Africa we have an online business Directory, and I thought writing a HTML Scraper would be a great first project in this language that speaks of “Convention over Configuration”, and “DRY”.

So where to begin?

Requirements:

Well, firstly, what are our requirements:

(a) A quick review of the business directory, revealed a list of Supermarkets available across Africa, and that will be the data we will mine for 

(b) Obviously the output should be in a “form” that we can use, CSV/PlainText.

( c) Perhaps a Library (Gem) that we can use to Scrape the HTML (that is manipulate the HTML/DOM), and that is NokoGiri.

(d) Understanding the layout of the pages and understanding the data structure (Name, Postal Address, Telephone etc). As with all websites of any value – CSS is inherent, and standards for presenting large amounts of data in the same structure (so we should be one up already)

Reviewing the Structure:

  1. Determine what the URL is going to look like and obviously because the information for the super-markets/stores are large they are paginated, so let’s see if we can find a way to reference them directly (that is get their pagination address).  As you can see below that seems to be the constant URL, and reviewing the “pagination” links, a number is added to the end in iterations of 10. That is; /S0914E/10 or /S0914E/20Url
  2. Secondly, breaking down the structure of a store/supermarket – we can almost guarantee they will be broken down by a <div>. I’m using Chrome and “Inspect Element” to narrow down the data and it’s structure. Each store is found in a class called “list-directory_entry_4”, the title for the store in a div class called “list-entryTitlebar” in the TEXT of the <a href>. The class “list-details” gives extra details about the store (location). Also there follows a URL that links to extra information which we will scrape as well found in class, “list-entryInfoBar”Structure of Store's Data

Code Time:

  • Some points worth noting, I use am STDOUT in Ruby to create our CSV. I call “sync” at the end to dump after I complete a page, else it will build in Memory (not good when dealing with tons of pages)
  • Secondly, NokoGiri supports XPath which is wonderful for accessing the HTML. Note I am using XPATH with starts with to match for some inconsistencies in store “divs”. Very handy! page.xpath("//div[starts-with(@class,'list-directory_entry_')]")
  •  In this section of code, I am creating the URL’s I intend to work with; that is the paginated pages with the content. So that I can apply the generic HTML scraping algorithm to it. 
  • URLs
 
  • Then iterate each URL, using NokoGiri, and use the XPath explained above to find the “div” for a store to scrape.XPath


  • Thereafter I grab the specific data I need using “css selectors” found in NokoGiri; Selector
 
 
 
             Lastly, I make use of .gsub(/s+/, “”) to remove any spaces that are not necessary. That’s it really, nice and simple.
  • Gsub



Code:

 

require ‘rubygems’
require ‘nokogiri’

require ‘open-uri’
#Create File for Output
$stdout = File.new(‘console.out’, ‘w’)
arrPages = Array.new
pageLoc = 10
#First Page (396 paginated pages)

arrPages.push “http://x.x.com/type/supermarkets/any/supermarkets/S0914E/”

 

for i in 1..396

arrPages.push “http://x.x.com/type/supermarkets/any/supermarkets/S0914E/” + pageLoc.to_s()

pageLoc = pageLoc + 10;

end
arrPages.each do |pageToScrape|
page = Nokogiri::HTML(open(pageToScrape))

page.xpath(“//div[starts-with(@class,’list-directory_entry_’)]”).each do |store|


result = String.new

iUrl = String.new

array = Array.new

 

# Get Details [Name] + [Location]

array.push store.css(“h2 a”).text + “|”

array.push store.css(“.list-details”).text + “|”
# Get About
# Get’s the More Info Page, filters that

iUrl = store.css(“.list-entryInfoBar a”)[0][‘href’]
infoPage = Nokogiri::HTML(open(iUrl))

array.push infoPage.css(“.phone”).text + “|”

array.push infoPage.css(“.fax”).text + “|”

array.push infoPage.css(“.email”).text + “|”

array.push infoPage.css(“.web”).text + “|”

array.push infoPage.css(“.address_1”).text + “|”

array.push infoPage.css(“.address_2”).text + “|”

 

puts array.join{” “}.gsub(/s+/, “”)

$stdout.sync = true
end

sleep 20

end


Helpful Links

  1. NokoGiri Tutorial
  2. Ruby in 20 minutes
  3. Other Ruby Help
  4. Bastards Book of Ruby

 

 

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone