Author Topic: Program accessing database  (Read 891 times)

0 Members and 2 Guests are viewing this topic.

Offline IrishYoga

  • Serf
  • *
  • Posts: 31
  • Cookies: -2
    • View Profile
Program accessing database
« on: 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.

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: Program accessing database
« Reply #1 on: February 28, 2014, 06:52:50 am »
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.
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Program accessing database
« Reply #2 on: February 28, 2014, 07:16:31 am »
Basically, I think Text parsing and web scraping is the terminology OP is looking for.

Offline IrishYoga

  • Serf
  • *
  • Posts: 31
  • Cookies: -2
    • View Profile
Re: Program accessing database
« Reply #3 on: February 28, 2014, 07:20:27 pm »
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:
Code: [Select]
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
« Last Edit: February 28, 2014, 07:41:02 pm by Kulverstukas »

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Program accessing database
« Reply #4 on: February 28, 2014, 07:43:45 pm »
I am not sure of what you are asking. Can you rephrase? code doesn't help.
« Last Edit: February 28, 2014, 07:44:06 pm by Kulverstukas »

Offline IrishYoga

  • Serf
  • *
  • Posts: 31
  • Cookies: -2
    • View Profile
Re: Program accessing database
« Reply #5 on: February 28, 2014, 07:49:05 pm »
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?

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Program accessing database
« Reply #6 on: February 28, 2014, 08:54:14 pm »
if i put this <td> into my code, will it always say 37000?
The values might change, the tags most likely won't.