2016-09-06 4 views
2

私はIndian patent search websiteのウェブスクレイパーを書いて特許に関するデータを取得しようとしています。ここに私がこれまで持っていたコードがあります。インド特許ウェブサイトの特許データのWebスクラップ

#import the necessary modules 
import urllib2 
#import the beautifulsoup functions to parse the data 
from bs4 import BeautifulSoup 

#mention the website that you are trying to scrape 
patentsite="http://ipindiaservices.gov.in/publicsearch/" 

#Query the website and return the html to the variable 'page' 
page = urllib2.urlopen(patentsite) 

#Parse the html in the 'page' variable, and store it in Beautiful Soup format 
soup = BeautifulSoup(page) 

print soup 

残念ながら、インドの特許のウェブサイトは堅牢ではないか、私は、この点でさらに進行するかどうかはわかりません。

これは上記のコードの出力です。

私は、私は会社名を提供するとしている与えたい事、スクレーパーは、その特定の会社のすべての特許を取得する必要があります。私はスクレーパーが特許を見つけるのに使う一連の入力を提供するなど、この部分を正しく行えれば他のことをしたいと思っています。しかし、私はさらに進めない部分で立ち往生しています。

このデータを取得する方法についてのあらゆる指針は非常に高く評価されます。

+1

あなたがリクエストしたhtmlがあります。しかし、このページは、すべてがJavaScript( 'app.js'内)で処理されるwebappとして作成されているようです。だからあなたのアプローチはほとんどうまくいかないでしょう。あなたはそのウェブサイトがあなたが使用できるAPIを提供しているかどうか調べたいかもしれません – UnholySheep

+0

ええ、私はそのような情報を探しました。それはそこにいるようではありません。私はいくつかのオンラインウェブスクレイパーを試しました。私はこのウェブサイトをスクラップすることはできませんか? –

+1

私が言ったように、それはウェブサイトよりウェブアプリケーションのほうが多い(それはJavaScriptを介して完全に駆動されるため)。あなたはセレンを使って何かをすることができるかもしれませんが、私はそれを使ったことはありません。 – UnholySheep

答えて

4

これは、のリクエストで行うことができます。ポストは、私たちがtime.timeで作成したタイムスタンプで1 のparamRC_http://ipindiaservices.gov.in/publicsearch/resources/webservices/search.phpにあります。 "field[]"

各値は、我々が値(S)の配列を渡している各キーを指定した後、あなたが*AND**OR*または*NOT*に選んだのかどうか"operator[]""fieldvalue[]"にし、今度の試合でそれぞれに[]を一致させる必要があり、それは何もせずに動作します。:

data = { 
    "publication_type_published": "on", 
    "publication_type_granted": "on", 
    "fieldDate": "APD", 
    "datefieldfrom": "19120101", 
    "datefieldto": "20160906", 
    "operatordate": " AND ", 
    "field[]": ["PA"], # claims,.description, patent-number codes go here 
    "fieldvalue[]": ["chris*"], # matching values for ^^ go here 
    "operator[]": [" AND "], # matching sql logic for ^^ goes here 
    "page": "1", # gives you next page results 
    "start": "0", # not sure what effect this actually has. 
    "limit": "25"} # not sure how this relates as len(r.json()[u'record']) stays 25 regardless 

import requests 
from time import time 

post = "http://ipindiaservices.gov.in/publicsearch/resources/webservices/search.php?_dc={}".format(
    str(time()).replace(".", "")) 

with requests.Session() as s: 
    s.get("http://ipindiaservices.gov.in/publicsearch/") 
    s.headers.update({"X-Requested-With": "XMLHttpRequest"}) 
    r = s.post(post, data=data) 
    print(r.json()) 

出力は次のようになります、私はそれを追加することはできませんポストにあまりにも多くのデータが存在するすべてのとおり

をあなたの特許情報をある

{u'Publication_Status': u'Published', u'appDate': u'2015/01/27', u'pubDate': u'2015/06/26', u'title': u'CORRUGATED PALLET', u'sourceID': u'inpat', u'abstract': u'\n A corrugated paperboard pallet is produced from two flat blanks which comprise a pallet top and a pallet bottom. The two blanks are each folded to produce only two parallel vertically extending double thickness ribs three horizontal panels two vertical side walls and two horizontal flaps. The ribs of the pallet top and pallet bottom lock each other from opening in the center of the pallet by intersecting perpendicularly with notches in the ribs. The horizontal flaps lock the ribs from opening at the edges of the pallet by intersecting perpendicularly with notches and the vertical sidewalls include vertical flaps that open inward defining fork passages whereby the vertical flaps lock said horizontal flaps from opening.\n ', u'Assignee': u'OLVEY Douglas A., SKETO James L., GUMBERT Sean G., DANKO Joseph J., GABRYS Christopher W., ', u'field_of_invention': u'FI10', u'publication_no': u'26/2015', u'patent_no': u'', u'application_no': u'642/DELNP/2015', u'UCID': u'WVJ4NVVIYzFLcUQvVnJsZGczcVRmSS96Vkh3NWsrS1h3Qk43S2xHczJ2WT0%3D', u'Publication_Type': u'A'} 

:あなたはレコードキーを使用している場合は

は、次のようなdictsのリストを取得します。

私達は私達のブラウザでいくつかの値を選択した場合は、あなたがすべてのオプションであることを確認してANDはデフォルトで、すべてのフィールド値フィールドオペレータラインアップの値を参照してくださいすることができます

enter image description here

enter image description here

ので、コードを把握したいものを選んで投稿してください。

+0

これは素晴らしいです!ありがとう。私はコードを書いて、さらにそれを使ってコードを作成します。ありがとう、トン。 –

+1

心配する必要はありません、あなたが望むどんな値を選んでも問題はありません。リストの整列とurlへの投稿を確認して、あなたが望むものをjson形式で得ることができます。 –

関連する問題