Connecting Tech Pros Worldwide Help | Site Map

Posts requests for a research article

Newbie
 
Join Date: Jul 2009
Posts: 10
#1: Jul 2 '09
Hi,

I'm not a programmer and I am doing a research for a non-profit report
about start-ups and branding. I want to digest some statistics. For
this I have a list of about 1 thousand names I want to check in the
trademark registry. This check can be done on this page:

http://www.wipo.int/ipdl/en/search/m...rch-struct.jsp

Currently, I have to type by hand the name into the formula field 4
(next to "Mark"). A pop-up window comes up and I then see, whether or
not this name is registered.

I would be already happy if I can provide the list an get 1000 pop-up
windows to check and close again. Even better would be to have an
output list telling me whether or not the brand is registered.

Is there anyone who could help me with this endeavour?

Acknoledgements will surely be publicly displayed.

Thank you so much for answering and giving me positive/negative
advice.

Cheers

Rico
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Jul 5 '09

re: Posts requests for a research article


Which language are you using? You could use Curl (see link) to target the form action page, get the response and parse it for each name. It'd be easier if the site offered a simpler interface to get the results more easily. There's no need to open 1,000 pop up windows.
Newbie
 
Join Date: Jul 2009
Posts: 10
#3: Jul 5 '09

re: Posts requests for a research article


Thanks a lot. Unfortunately I cannot change the interface as it's an official site of the trademark registry. Curl would be ok, if you could help me.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Jul 5 '09

re: Posts requests for a research article


Either use it on the command line, or if you know one of the supported languages (30 or so of them), use them instead. Which one can you program in?
Newbie
 
Join Date: Jul 2009
Posts: 10
#5: Jul 5 '09

re: Posts requests for a research article


Hi acoder. Sorry to bother you. As I wrote at the beginning, I am not a programmer. I know some css, xml.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#6: Jul 6 '09

re: Posts requests for a research article


Ah, sorry, I missed that. I'm afraid that this is going to be difficult without some programming. What you can do is look at the cURL command line options (manual) and see if it's possible to make multiple requests. There's probably a tool out there to do this for you, but I'm not aware of any. Having said that, it shouldn't be difficult for someone to program one.
Newbie
 
Join Date: Jul 2009
Posts: 10
#7: Jul 6 '09

re: Posts requests for a research article


Thanks a lot for your help!
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#8: Jul 7 '09

re: Posts requests for a research article


If you could specify what on the results page deems the 'mark' branded, then I could help you pull the data (using PHP).

I can POST the data to the landing page, and retrieve the results, but to parse the results I need to know what you want from them; the 'Verbal Elements' possibly?
Newbie
 
Join Date: Jul 2009
Posts: 10
#9: Jul 7 '09

re: Posts requests for a research article


Hi Markus

Thank you so much for helping me.

The results page (a pop-up window) will list a part called "Search Summary":

Search Summary
MAR/supertext: 0 occurrences in 0 records.

So MAR means "Mark" (field) "/" followed by searched name "supertext"

My interest ist "name of input" and number of occurences and number of records.

Let me know if you need more information. In what format would you need the list of names?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#10: Jul 7 '09

re: Posts requests for a research article


Quote:

Originally Posted by ricowyder View Post

Hi Markus

Thank you so much for helping me.

The results page (a pop-up window) will list a part called "Search Summary":

Search Summary
MAR/supertext: 0 occurrences in 0 records.

So MAR means "Mark" (field) "/" followed by searched name "supertext"

My interest ist "name of input" and number of occurences and number of records.

Let me know if you need more information. In what format would you need the list of names?

Okay - so you want to retrieve the part '0 occurrences in 0 records'? We can do that.

The names would, for simplicity's sake, be in a .txt file with each name on a new row. But, I don't the file - you keep it - I'll just help you with the coding.

Mark (will BRB in 10 minutes).
Newbie
 
Join Date: Jul 2009
Posts: 10
#11: Jul 7 '09

re: Posts requests for a research article


Hi Mark, great. I'll put the names in a .txt one name each line. Thank you soo much!
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#12: Jul 7 '09

re: Posts requests for a research article


You'll need PHP set up on your system - that ain't hard to do, though.

Anyway, here's the source (it's simple and dirty, but does the job).

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. // Prevent ourselves from timing out
  4. set_time_limit(0);
  5. // Error reporting max
  6. error_reporting(E_ALL);
  7.  
  8. // The names that we will be searching for.
  9. $names = file('/path/to/file.txt');
  10. // You could it with an array, like so:
  11. //$names = array(
  12. //    'Mark', 'Sarah', 'Rachel',
  13. //    'Chris', 'Jake', 'Josh'
  14. //);
  15.  
  16. // Create a single resource for cURL.
  17. $curl = curl_init('http://www.wipo.int/cgi-mad/guest/bool_srch5?ENG+11');
  18. $ref  = "http://www.wipo.int/ipdl/en/search/madrid/search-struct.jsp";
  19. // Set some options that don't change.
  20. curl_setopt($curl,     CURLOPT_RETURNTRANSFER,     1);
  21. curl_setopt($curl,     CURLOPT_POST,                1);
  22. curl_setopt($curl,       CURLOPT_FOLLOWLOCATION,        1);
  23. curl_setopt($curl,     CURLOPT_REFERER,            $ref);
  24.  
  25. // Our post array: we'll be changing only one key.
  26. $post = array(
  27.     'ADDITIONAL_FIELD_1' => '',
  28.     'ADDITIONAL_FIELD_2' => '',
  29.     'ADDITIONAL_FIELD_3' => 'IMAGE',
  30.  
  31.     'ADDITIONAL_FIELD_COUNT'  => 3,
  32.     'ADDITIONAL_FIELD_COUNT'  => 2,
  33.     'ADDITIONAL_TERM_COUNT'  => 2,
  34.  
  35.     'BRIEF_ELEMENT_SET' => 'HITNUM,PN,MAR',
  36.     'DBSELECT2'            => 'MADRID-FULL.vdb',
  37.     'DISPLAYCOUNT'      => 1000, // Override the default '25 per page' crap.
  38.     'ELEMENT_SET'    => 'BASICHTML-ENG',
  39.  
  40.     'FIELD_1'            => 'IRN',
  41.     'FIELD_2'            => 'HOL',
  42.     'FIELD_3'            => 'REP',
  43.     'FIELD_4'            => 'MAR',
  44.     'FIELD_5'            => 'VC',
  45.     'FIELD_6'            => 'NCL',
  46.     'FIELD_7'            => 'GSE',
  47.     'FIELD_8'            => 'GSF',
  48.     'FIELD_9'            => 'GSES',
  49.     'FIELD_10'            => 'ORI',
  50.     'FIELD_11'            => 'OBA',
  51.     'FIELD_12'            => 'OBR',
  52.     'FIELD_13'            => 'DSA',
  53.  
  54.     'OPERATOR_1'        => 'AND',
  55.     'OPERATOR_2'        => 'AND',
  56.     'OPERATOR_3'        => 'AND',
  57.     'OPERATOR_4'        => 'AND',
  58.     'OPERATOR_5'        => 'AND',
  59.     'OPERATOR_6'        => 'AND',
  60.     'OPERATOR_7'        => 'AND',
  61.     'OPERATOR_8'        => 'AND',
  62.     'OPERATOR_9'        => 'AND',
  63.     'OPERATOR_10'    => 'AND',
  64.     'OPERATOR_11'    => 'AND',
  65.     'OPERATOR_12'    => 'AND',
  66.  
  67.     'RANKTYPE'        => 'KEY',
  68.  
  69.     'SEARCH_TYPE_1'    => '',
  70.     'SEARCH_TYPE_2'    => '',
  71.     'SEARCH_TYPE_3'    => '',
  72.     'SEARCH_TYPE_4'    => '',
  73.     'SEARCH_TYPE_5'    => 'ANY',
  74.     'SEARCH_TYPE_6'    => 'ANY',
  75.     'SEARCH_TYPE_7'    => '',
  76.     'SEARCH_TYPE_8'    => '',
  77.     'SEARCH_TYPE_9'    => '',
  78.     'SEARCH_TYPE_10'    => '',
  79.     'SEARCH_TYPE_11'    => '',
  80.     'SEARCH_TYPE_12'    => '',
  81.     'SEARCH_TYPE_13'    => '',
  82.  
  83.     'SEPDISPLAY'        => '',
  84.  
  85.     'TERM_1'            => '',
  86.     'TERM_2'            => '',
  87.     'TERM_3'            => '',
  88.     // Missing TERM_4
  89.     'TERM_5'            => '',
  90.     'TERM_6'            => '',
  91.     'TERM_7'            => '',
  92.     'TERM_8'            => '',
  93.     'TERM_9'            => '',
  94.     'TERM_10'            => '',
  95.     'TERM_11'            => '',
  96.     'TERM_12'            => '',
  97.     'TERM_13'            => '',
  98.  
  99.     'NUM_TERMS'        => '13'
  100. );
  101.  
  102. $post_string = '';
  103. // HACK! Icky :(
  104. foreach( $post as $key => $val )
  105. {
  106.     $post_string .= "$key=$val&";
  107. }
  108.  
  109. // Prevent ourselves from timing out
  110. set_time_limit(0);
  111. // Error reporting max
  112. error_reporting(E_ALL);
  113.  
  114. $results = array();
  115. // Now we process
  116. foreach($names as $name) {
  117.  
  118.     // Inject POST into curl
  119.     curl_setopt($curl, CURLOPT_POSTFIELDS, $post_string . "TERM_4=$name");
  120.     // Thanks to CURLOPT_RETURNTRANSFER we can
  121.     // save whatever results our query generates.
  122.     $return = curl_exec($curl);
  123.  
  124.     preg_match('/([0-9]+ records)/', $return, $matches);
  125.  
  126.     $results[$name] = $matches[1];
  127. }
  128.  
  129. print_r($results);
  130.  
  131. curl_close($curl);
  132.  
Save it as 'curl.php' and then, in a terminal (command line) type 'php /path/to/curl.php' (substituting the /path/to/ with the actual path ;).

You'll receive the output inside the terminal.

If you'd like the output piped to a text file, change the command to this: php /path/to/curl.php > /path/to/output.txt

The second path does not have to exist - the terminal will create it (or overwrite it if it does exist).

Let me know how you get on & if you need a hand.

- mark.
Newbie
 
Join Date: Jul 2009
Posts: 10
#13: Jul 7 '09

re: Posts requests for a research article


Thanks :-) I'll do my best and will let you know...
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#14: Jul 7 '09

re: Posts requests for a research article


Quote:

Originally Posted by ricowyder View Post

Thanks :-) I'll do my best and will let you know...

I updated the above code - so make sure you are using the correct one.
Newbie
 
Join Date: Jul 2009
Posts: 10
#15: Jul 7 '09

re: Posts requests for a research article


Hi Markus

It did so:

php C:\curl.php > C:\new.txt

Prompts: command "php" is either typed wrong or could not be found

Do I need something else to run this except the cmd?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#16: Jul 7 '09

re: Posts requests for a research article


Quote:

Originally Posted by ricowyder View Post

Hi Markus

It did so:

php C:\curl.php > C:\new.txt

Prompts: command "php" is either typed wrong or could not be found

Do I need something else to run this except the cmd?

Do you gots PHP installed on your system? If so, you might need to update your PATH system variable so that it can find the PHP executable.

So, what directory is PHP at?
Newbie
 
Join Date: Jul 2009
Posts: 10
#17: Jul 7 '09

re: Posts requests for a research article


Hi Mark

I've tried to install apache server and php to run your code. Unfortunately, I wasn't that successful at it. Is there any way I can run this by uploading it on my server and by loading the file? Sorry for all inconvenience, you're of great help.

Wishes

Rico
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#18: Jul 7 '09

re: Posts requests for a research article


Quote:

Originally Posted by ricowyder View Post

Hi Mark

I've tried to install apache server and php to run your code. Unfortunately, I wasn't that successful at it. Is there any way I can run this by uploading it on my server and by loading the file? Sorry for all inconvenience, you're of great help.

Wishes

Rico

You don't need apache to run it - but, sure.

Just upload it to your server. If PHP has cURL enabled (off by default - check your php.ini*), then it'll output the results to the screen.

* In your php.ini, look for the line ';extension=php_curl.dll' (or something like that) and remove the preceeding ';'.

Let me know if you need anymore help,

Mark.

PS: Remember to restart your server if you make changes to the configuration.
Newbie
 
Join Date: Jul 2009
Posts: 10
#19: Jul 8 '09

re: Posts requests for a research article


Hi Mark

A friend helped me out running it on their server. I tested it with 4 entries (form a .txt) and got this output:

PHP Notice: Undefined offset: 1 in M:\web\uat\ftp_exchange\Rico\curl.php on line 127

Array

(

[apple

] => 57 records

[dell

] => 52 records

[migros

] => 26 records

[laposte

] => 0 records

[wuala] =>

)

Which is great. I started running my list of 20'000+ entries (I hope this doesn't shock you). Apparently, it's quite slow and therefore works well. I didn't got blocked.

However, the first line PHP Notice appears again and again. I am not sure if all sets are processed.

Before I start running all through, I wanted to ask you the following:
1. how can I get rid of this PHP Notice?
2. I have some stranges company names like "A Beautiful Code" or "@Compass" or "23/6" - will spaces or symbols influence the query?

A sample of my text file:

A Beautiful Site
A Big Important Company
A Blog.Branding-Studio
A-1 Technology
a-steroids
A.T. Kearney
A1-4 Electronics, Inc.
A10 Networks
A123Systems
A1Vacations
A2 ltd
A2B Office Products
A2B Office Technology

Could they cause any problems with you script?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#20: Jul 8 '09

re: Posts requests for a research article


That is maybe an error on my part - I'll check as soon as I can (just got in and I've gotta go back out).

Mark (will be back later).
Reply

Tags
html, post request