0

Ok, in work I use a particular system to look up part numbers for products. It's accessed in the browser and can only be accessed by company machines and I have a log on to use the system. Once logged in, I type in the part number and it prints a list into a rich text field with the part number, serial number, description and some other bits of info. It doesnt have the ability to search for multiple part numbers, so I literally have to type in the first, wait for the result, then the second, etc. What I'm looking to do is write some code that will loop through a text file and print out part of the result into the text file next to each part number. This kind of code I'm used to.

My problem however is that I dont know what the source code / function is for this company owned system. If I view the source I cant see a js file or anything similar with what I would think the script would live in, so assume its server side. If I watch the requests, I can see the parameters being passed, but I dont know how I could recreate this in code and obtain a result. Would be nice if it spat out some json, but I dont think its that easy :-)

Any pointers to get me going and areas I should look at?

Thoughts appreciated.

  • You can check the onclick function (when you search you press them) to see the destination of the Ajax call. – Goikiu Dec 30 '13 at 13:40
  • If the system was built by a competent programmer then this task is going to be very difficult/impossible. I am confused by the entire text file idea because if you don't have access to the server-side then your text file will **quickly** become out of date. – MonkeyZeus Dec 30 '13 at 13:44
  • However I personally find Google Chrome's development tools easiest to use. Press F12 and go to the Network tab, refresh the page, search for a part number, and watch for requests. If you want to see the JS then click on a JS file from the list in that tab. – MonkeyZeus Dec 30 '13 at 13:48
  • the requests *have to* be generated by javascript code, triggered by button clicks or `onchange` events on `input` fields. You have to identify the request as suggested by Gavriel or user2191572 and try to mimic it, eventually using an approach like http://stackoverflow.com/questions/5918401/simulate-jquery-ajax-request-in-php (supposing it is an ajax request made by jquery) – furins Dec 30 '13 at 13:50

1 Answers1

0

You can view the response headers in the browser's network tab, if it's php, by default it adds a header that you'll recognize.

But, how will you deploy your server side code if you don't have access to the server? And if you do, then why do you need to guess the language like this?

Gavriel
  • 18,880
  • 12
  • 68
  • 105
  • is this answer specific for chrome/webkit/firebug/other? I think that network tab is not available on IE7, for instance :) – furins Dec 30 '13 at 13:44
  • thanks Gavriel, when I view the response, I just get content-length, type, date and the server, nothing else...? –  Dec 30 '13 at 13:51
  • Server is what you need – Gavriel Dec 30 '13 at 13:51
  • hmm, what do I do with it, it just gives me "apache-coyote/1.1" –  Dec 30 '13 at 13:52
  • you google it, and then you understand that it's in Java – Gavriel Dec 30 '13 at 13:53
  • in reply to your edit, I guess what I'm looking to do is write some code that queries the server in the same way this web-system does so I can speed up my work rate saving me copying and pasting in values in the search field... –  Dec 30 '13 at 13:58
  • 2
    If I were you, I wouldn't try to touch the server (they won't let you anyway probably), and try to make a javascript solution using the same "public" api, that your current solution uses – Gavriel Dec 30 '13 at 14:00
  • i agree, thats what i'm trying to do, but not sure how to recreate the requests. i'll keep tinkering –  Dec 30 '13 at 14:02
  • 1
    Unless you have access to modify the files on the web server then any attempt at duplicating an AJAX request is 99% likely to fail due to the same-origin policy – MonkeyZeus Dec 30 '13 at 14:04
  • thanks, i'll bear that in mind. appreciate the dialogue on this everyone, cheers. –  Dec 30 '13 at 14:08