EvilZone
Programming and Scripting => Projects and Discussion => : IrishYoga February 28, 2014, 04:31:18 AM
-
How could i create a program to access a particular object's data in a database? I don't want to keep having to go to that website and checking the number, so i wanted to create a program that when i ran it, would tell me the current number of the item in question. I've searched Google for both C and Python solutions, but to no avail.
-
Wait, the database is offsite? Ok. You obviously know you have to have access/credentials for that.
But if you do, though not sure which database it is, am sure coding a program that executes Database statements and queries for that specific need not take you a whole search of google.
To save you the pain of searching everytime you need to code something, grab some SQL book and learn some queries, et-la. OR else you will never learn by copy pasting code.
-
Basically, I think Text parsing and web scraping is the terminology OP is looking for.
-
Thank you! Yes, that was what i was looking for. I've already looked into Web Scraping and it has solved my problem! I have one question, however. The source code says the number of the item, and i thought the source code would only show the logic behind the printed number on the actual website which could either facilitate or make it harder for me. Will the number constantly change in my program or will it stay as it was when i first put it into the program? I'll put in some pseudo code to help you understand:
import urllib
import re
url = "http://blahblah.com"
regex = '<value>(.+?)</value>'
pattern = re.compile(regex)
htmlfile = urllib.urlopen(url)
htmltext = htmlfile.read()
value = re.findall(pattern,htmltext)
print value
-
I am not sure of what you are asking. Can you rephrase? code doesn't help.
-
ok so i looked into the source code thinking that it would have some <script calculate> blah blah</script> but it actually said something along the lines of <td> 37000 </td> so what i'm asking is if i put this <td> into my code, will it always say 37000?
-
if i put this <td> into my code, will it always say 37000?
The values might change, the tags most likely won't.