From c8a1096952f7863710a960d350a031e1aa4cf8cd Mon Sep 17 00:00:00 2001 From: Shaghayegh Date: Sun, 26 Feb 2023 17:57:54 +0100 Subject: [PATCH] finished draft with config files --- Bachelorarbeit/__init__.py | 0 .../__pycache__/__init__.cpython-39.pyc | Bin 0 -> 150 bytes .../__pycache__/settings.cpython-39.pyc | Bin 0 -> 435 bytes Bachelorarbeit/data_config.ini | 87 + Bachelorarbeit/items.py | 12 + Bachelorarbeit/middlewares.py | 103 + Bachelorarbeit/pipelines.py | 13 + Bachelorarbeit/settings.py | 93 + Bachelorarbeit/spiders/__init__.py | 4 + .../__pycache__/__init__.cpython-39.pyc | Bin 0 -> 158 bytes .../__pycache__/project_data.cpython-39.pyc | Bin 0 -> 4351 bytes Bachelorarbeit/spiders/project_data.py | 324 + Projectlinks/links_config.ini | 2 + Projectlinks/links_extractor.py | 26 +- README.md | 50 + Scraped-data/BMBF_all_data.json | 3324 ++ Scraped-data/DFG_all_data.json | 4705 +++ Scraped-data/EU_all_data.json | 26406 ++++++++++++++++ Scrapy_or_Selenium.py | 100 + scrapy.cfg | 11 + .../__pycache__/selenium.cpython-310.pyc | Bin 0 -> 4758 bytes .../__pycache__/selenium.cpython-39.pyc | Bin 0 -> 4738 bytes selenium_script/selenium.py | 209 + 23 files changed, 35453 insertions(+), 16 deletions(-) create mode 100644 Bachelorarbeit/__init__.py create mode 100644 Bachelorarbeit/__pycache__/__init__.cpython-39.pyc create mode 100644 Bachelorarbeit/__pycache__/settings.cpython-39.pyc create mode 100644 Bachelorarbeit/data_config.ini create mode 100644 Bachelorarbeit/items.py create mode 100644 Bachelorarbeit/middlewares.py create mode 100644 Bachelorarbeit/pipelines.py create mode 100644 Bachelorarbeit/settings.py create mode 100644 Bachelorarbeit/spiders/__init__.py create mode 100644 Bachelorarbeit/spiders/__pycache__/__init__.cpython-39.pyc create mode 100644 Bachelorarbeit/spiders/__pycache__/project_data.cpython-39.pyc create mode 100644 Bachelorarbeit/spiders/project_data.py create mode 100644 README.md create mode 100644 Scraped-data/BMBF_all_data.json create mode 100644 Scraped-data/DFG_all_data.json create mode 100644 Scraped-data/EU_all_data.json create mode 100644 Scrapy_or_Selenium.py create mode 100644 scrapy.cfg create mode 100644 selenium_script/__pycache__/selenium.cpython-310.pyc create mode 100644 selenium_script/__pycache__/selenium.cpython-39.pyc create mode 100644 selenium_script/selenium.py diff --git a/Bachelorarbeit/__init__.py b/Bachelorarbeit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Bachelorarbeit/__pycache__/__init__.cpython-39.pyc b/Bachelorarbeit/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..99d742ad07b78ac89d974dd2d7b4703783365607 GIT binary patch literal 150 zcmYe~<>g`kf+DfHWDxxrL?8o3AjbiSi&=m~3PUi1CZpdI zQ=E~QofzZf7~_ literal 0 HcmV?d00001 diff --git a/Bachelorarbeit/__pycache__/settings.cpython-39.pyc b/Bachelorarbeit/__pycache__/settings.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..061297dff13aff8b623ed7bcbdb772becb21f441 GIT binary patch literal 435 zcmZ9J%}&BV5XW069~waq#)~)Og@ZkK5TnM}(uFjkyLGz+Y??HcU7-NT$^4VwWIi%8NvpN5DLd_cO*<`3``o}^(-k}@=VwZ&7HU+V>7h>butF zyc3dbj8t|&CL~5Sc#`KBJdQv>;=T(90Q=a5L^W_de+WDPiA7ulblV|28M3vKYOBoiU0rr literal 0 HcmV?d00001 diff --git a/Bachelorarbeit/data_config.ini b/Bachelorarbeit/data_config.ini new file mode 100644 index 0000000..0ec8c44 --- /dev/null +++ b/Bachelorarbeit/data_config.ini @@ -0,0 +1,87 @@ +[BMBF] +allowed-domain = foerderportal.bund.de +container = //div[@class='detailAnsicht'] +foerderkennzeichen = normalize-space(.//div[@class='detailAnsichtItem']/div[contains(text(),'Förderkennzeichen')]/parent::*/div[2]/text()) +thema = normalize-space(.//div[@class='detailAnsichtItem']/div[contains(text(),'Thema')]/parent::*/div[2]/text()) +verbund = normalize-space(.//div[@class='detailAnsichtItem']/div[contains(text(),'Verbund')]/parent::*/div[2]/form[@id='sucheVerbund']/a/text()) +foerdersumme = normalize-space(.//div[@class='detailAnsichtItem']/div[contains(text(),'Fördersumme')]/parent::*/div[2]/text()) +ressort = normalize-space(.//div[@class='detailAnsichtItem']/div[contains(text(),'Ressort')]/parent::*/div[2]/text()) +projekttraeger = normalize-space(.//div[@class='detailAnsichtItem']/div[contains(text(),'Projektträger')]/parent::*/div[2]/text()) +laufzeit = normalize-space(.//div[@class='detailAnsichtItem']/div[contains(text(),'Laufzeit')]/parent::*/div[2]/text()) +leistungsplansystematik = normalize-space(.//div[@class='detailAnsichtItem']/div[contains(text(),'Leistungsplansystematik')]/parent::*/div[2]/text()) +foerderart = normalize-space(.//div[@class='detailAnsichtItem']/ div[contains(text(),'Förderart')]/parent::*/div[2]/text()) +foerderprofil = normalize-space(.//div[contains(text(),'Förderprofil')]/parent::*/div[2]/text()) +zuwendungsempfaenger = //div[@class='detailAnsichtItem' and @aria-label='Name, Ort, Bundesland und Staat des Zuwendungsempfängers']/child::div[1] +z_empf = normalize-space(./following-sibling::div[1]/text()) +z_empf_ort = normalize-space(./following-sibling::div[3]/text()) +z_empf_Bundesland_stadt = normalize-space(./following-sibling::div[5]/text()) +Ausfuehrende_Stellen = //div[@class='detailAnsichtItem' and @aria-label='Name, Ort, Bundesland und Staat der Ausführenden Stelle']/child::div[1] +a_stelle = normalize-space(./following-sibling::div[1]/text()) +a_stelle_ort = normalize-space(./following-sibling::div[3]/text()) +a_stelle_Bundesland_stadt = normalize-space(./following-sibling::div[5]/text()) + + +[DFG] +allowed-domain = gepris.dfg.de +details_container = //div[@class='content_inside detailed']/div[@class='details'] +title = normalize-space(.//h1[@class='facelift']/text()) +antragsteller = .//div/span[@class='name' and contains(text(), ' Antragsteller')]/parent::*/span[@class='value']/descendant::a/text() +fachliche_Zuordnung = .//div[@class='firstUnderAntragsbeteiligte']/span[@class='value']/text() +foerderung = normalize-space(.//div/span[@class='value' and contains(text(), 'Förderung')]/text()) +Projektkennung = normalize-space(.//div[@class='projektnummer']/span[@class='value']/text()) +Website = .//div//span[@class='value']/a[@title='Webseite' and @class='extern']/@href +beschreibung_container = //div[@class='content_frame']/div[@id='projektbeschreibung'] +project_text = normalize-space(.//div[@id='projekttext']/text()) +DFG_Verfahren = normalize-space(.//div/span[contains(text(),' DFG-Verfahren')]//parent::*/span[2]/text()) +geraetegruppe = normalize-space(.//div/span[contains(text(),' Gerätegruppe')]//parent::*/span[2]/text()) +grossgereate = normalize-space(.//div/span[contains(text(),'Großgeräte')]//parent::*/span[2]/text()) +antragstellende_Institution = normalize-space(.//div/span[contains(text(),'Antragstellende Institution')]//parent::*/span[2]/a/text()) +leiter = normalize-space(.//div/span[contains(text(),'Leiter')]//parent::*/span[2]/a/text()) +mitverantwortliche = .//div/span[contains(text(),'Mitverantwortliche')]//parent::*/span[2]/a[@class='intern']/text() +beteiligte_Person = .//div/span[contains(text(),' Beteiligte Person')]//parent::*/span[2]/descendant::a[@class='intern']/text() +teilprojekt_zu = .//div/span[contains(text(),'Teilprojekt zu')]//parent::*/span[2]/descendant::a[@class='intern']/text() +kooperationspartner = .//div/span[contains(text(),' Kooperationspartner')]//parent::*/span[2]/descendant::a[@class='intern']/text() +internationaler_Bezug = normalize-space(.//div/span[contains(text(),'Internationaler Bezug')]//parent::*/span[2]/text()) +Sprecher = .//div/span[contains(text(),' Sprecher')]//parent::*/span[2]/descendant::a[@class='intern']/text() +beteiligte_Institution = .//div/span[contains(text(),' Beteiligte Institution')]//parent::*/span[2]/child::*/text() +beteiligte_Hochschule = .//div/span[contains(text(),' Beteiligte Hochschule')]//parent::*/span[2]/descendant::a/text() +mitantragstellende_Institution= normalize-space(.//div/span[contains(text(),' Mitantragstellende Institution')]//parent::*/span[2]/descendant::a/text()) +beteiligte_Wissenschaftler = .//div/span[contains(text(),' beteiligte Wissenschaftlerinnen / beteiligte Wissenschaftler')]//parent::*/span[2]/descendant::a[@class='intern']/text() +IGK_Partnerinstitution = normalize-space(.//div/span[contains(text(),' IGK-Partnerinstitution')]//parent::*/span[2]/a[@class='intern']/text()) +partnerorganisation = normalize-space(.//div/span[contains(text(),' Partnerorganisation')]//parent::*/span[2]/a[@class='intern']/text()) +gastgeber = .//div/span[contains(text(),' Gastgeber')]//parent::*/span[2]/descendant::a[@class='intern']/text() +anwendungspartner = .//div/span[contains(text(),' Anwendungspartner')]//parent::*/span[2]/descendant::a[@class='intern']/text() +beteiligte_Fachrichtungen = normalize-space(.//div/span[contains(text(),'Beteiligte Fachrichtungen')]//parent::*/span[2]/text()) +ehemalige_Antragsteller = .//div/span[contains(text(),' Ehemalige Antragsteller')]//parent::*/span[2]/descendant::a/text() + +[EU] +title_loading_phase = //div[contains(@class, 'c-header-project__title-container')]/h1[contains(@class, 'c-header-project__title')] +title = //div[contains(@class, 'c-header-project__title-container')]/h1[contains(@class, 'c-header-project__title')] +content_container_loading_phase = //article +content_container = //article +objective = //h2[contains(text(), ' Objective ')]/parent::*/p[contains(@class, 'c-article__text')] +programme = //h3[contains(text(), 'Programme(s)')]/parent::*/ul/li/a +project_description = //h2[contains(text(), 'Project description')]//parent::*//p[contains(@class, 'c-project-description__text') or contains(@class, 'c-article__text')] +proposal = //h3[contains(text(), 'Call for proposal')]/parent::*/p/span +fields_of_science_list = //h3[contains(text(), 'Fields of science')]/parent::*/ul/li[@class='ng-star-inserted']/child::span[@class='ng-star-inserted'] +fields_of_science = ./a +topics = //h3[contains(text(), 'Topic(s)')]/parent::*/ul/li/a +funding_scheme = //h3[contains(text(), 'Funding Scheme')]/parent::*/a +coordinator = //h3[contains(text(), 'Coordinator')]/parent::*//div[contains(@class, 'c-part-info__title')] +coordinator_address = //h3[contains(text(), 'Coordinator')]/parent::*//div[contains(text(), ' Address ')]/parent::*/div[contains(@class, 'c-part-info__content')] +coordinator_region = //h3[contains(text(), 'Coordinator')]/parent::*//div[contains(text(), 'Region')]/parent::*/div[contains(@class, 'c-part-info__content')] +coordinator_activity_type = //h3[contains(text(), 'Coordinator')]/parent::*//div[contains(text(), 'Activity type')]/parent::*/div[contains(@class, 'c-part-info__content')] +coordinator_net_EU_contribution = //h3[contains(text(), 'Coordinator')]/parent::*//div[contains(text(), 'Net EU contribution')]/parent::*/div[contains(@class, 'c-part-info__content')] +coordinator_other_fundings = //h3[contains(text(), 'Coordinator')]/parent::*//div[contains(text(), 'Other funding')]/parent::*/div[contains(@class, 'c-part-info__content')] +coordinator_link = //h3[contains(text(), 'Coordinator')]/parent::*//div[contains(text(), 'Links')]/parent::*//span/a +project_info_container_loading_phase = //app-project-info//div[@class='c-project-info__content'] +project_info_container = //app-project-info//div[@class='c-project-info__content'] +grant_agreement_ID = //div[contains(text(), 'Grant agreement ID')] +doi = //span[contains(text(), 'DOI')]/parent::*/a +project_acronym = //div[@class='c-project-info__acronym'] +start_date = //span[contains(text(), 'Start date')]/parent::* +end_date = //span[contains(text(), 'End date')]/parent::* +funded_under = //span[contains(text(), 'Funded under')]/parent::*/ul/li +overal_budget = //span[contains(text(), 'Overall budget') or contains(text(), 'Total cost')]/parent::* +EU_contribution = //span[contains(text(), 'EU contribution')]/parent::* + diff --git a/Bachelorarbeit/items.py b/Bachelorarbeit/items.py new file mode 100644 index 0000000..c31a073 --- /dev/null +++ b/Bachelorarbeit/items.py @@ -0,0 +1,12 @@ +# Define here the models for your scraped items +# +# See documentation in: +# https://docs.scrapy.org/en/latest/topics/items.html + +import scrapy + + +class BachelorarbeitItem(scrapy.Item): + # define the fields for your item here like: + # name = scrapy.Field() + pass diff --git a/Bachelorarbeit/middlewares.py b/Bachelorarbeit/middlewares.py new file mode 100644 index 0000000..222fad0 --- /dev/null +++ b/Bachelorarbeit/middlewares.py @@ -0,0 +1,103 @@ +# Define here the models for your spider middleware +# +# See documentation in: +# https://docs.scrapy.org/en/latest/topics/spider-middleware.html + +from scrapy import signals + +# useful for handling different item types with a single interface +from itemadapter import is_item, ItemAdapter + + +class BachelorarbeitSpiderMiddleware: + # Not all methods need to be defined. If a method is not defined, + # scrapy acts as if the spider middleware does not modify the + # passed objects. + + @classmethod + def from_crawler(cls, crawler): + # This method is used by Scrapy to create your spiders. + s = cls() + crawler.signals.connect(s.spider_opened, signal=signals.spider_opened) + return s + + def process_spider_input(self, response, spider): + # Called for each response that goes through the spider + # middleware and into the spider. + + # Should return None or raise an exception. + return None + + def process_spider_output(self, response, result, spider): + # Called with the results returned from the Spider, after + # it has processed the response. + + # Must return an iterable of Request, or item objects. + for i in result: + yield i + + def process_spider_exception(self, response, exception, spider): + # Called when a spider or process_spider_input() method + # (from other spider middleware) raises an exception. + + # Should return either None or an iterable of Request or item objects. + pass + + def process_start_requests(self, start_requests, spider): + # Called with the start requests of the spider, and works + # similarly to the process_spider_output() method, except + # that it doesn’t have a response associated. + + # Must return only requests (not items). + for r in start_requests: + yield r + + def spider_opened(self, spider): + spider.logger.info('Spider opened: %s' % spider.name) + + +class BachelorarbeitDownloaderMiddleware: + # Not all methods need to be defined. If a method is not defined, + # scrapy acts as if the downloader middleware does not modify the + # passed objects. + + @classmethod + def from_crawler(cls, crawler): + # This method is used by Scrapy to create your spiders. + s = cls() + crawler.signals.connect(s.spider_opened, signal=signals.spider_opened) + return s + + def process_request(self, request, spider): + # Called for each request that goes through the downloader + # middleware. + + # Must either: + # - return None: continue processing this request + # - or return a Response object + # - or return a Request object + # - or raise IgnoreRequest: process_exception() methods of + # installed downloader middleware will be called + return None + + def process_response(self, request, response, spider): + # Called with the response returned from the downloader. + + # Must either; + # - return a Response object + # - return a Request object + # - or raise IgnoreRequest + return response + + def process_exception(self, request, exception, spider): + # Called when a download handler or a process_request() + # (from other downloader middleware) raises an exception. + + # Must either: + # - return None: continue processing this exception + # - return a Response object: stops process_exception() chain + # - return a Request object: stops process_exception() chain + pass + + def spider_opened(self, spider): + spider.logger.info('Spider opened: %s' % spider.name) diff --git a/Bachelorarbeit/pipelines.py b/Bachelorarbeit/pipelines.py new file mode 100644 index 0000000..e98f09b --- /dev/null +++ b/Bachelorarbeit/pipelines.py @@ -0,0 +1,13 @@ +# Define your item pipelines here +# +# Don't forget to add your pipeline to the ITEM_PIPELINES setting +# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html + + +# useful for handling different item types with a single interface +from itemadapter import ItemAdapter + + +class BachelorarbeitPipeline: + def process_item(self, item, spider): + return item diff --git a/Bachelorarbeit/settings.py b/Bachelorarbeit/settings.py new file mode 100644 index 0000000..21e55e4 --- /dev/null +++ b/Bachelorarbeit/settings.py @@ -0,0 +1,93 @@ +# Scrapy settings for Bachelorarbeit project +# +# For simplicity, this file contains only settings considered important or +# commonly used. You can find more settings consulting the documentation: +# +# https://docs.scrapy.org/en/latest/topics/settings.html +# https://docs.scrapy.org/en/latest/topics/downloader-middleware.html +# https://docs.scrapy.org/en/latest/topics/spider-middleware.html + +BOT_NAME = 'Bachelorarbeit' + +SPIDER_MODULES = ['Bachelorarbeit.spiders'] +NEWSPIDER_MODULE = 'Bachelorarbeit.spiders' + + +# Crawl responsibly by identifying yourself (and your website) on the user-agent +#USER_AGENT = 'Bachelorarbeit (+http://www.yourdomain.com)' + +# Obey robots.txt rules +ROBOTSTXT_OBEY = True + +# Configure maximum concurrent requests performed by Scrapy (default: 16) +#CONCURRENT_REQUESTS = 32 + +# Configure a delay for requests for the same website (default: 0) +# See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay +# See also autothrottle settings and docs +#DOWNLOAD_DELAY = 3 +# The download delay setting will honor only one of: +#CONCURRENT_REQUESTS_PER_DOMAIN = 16 +#CONCURRENT_REQUESTS_PER_IP = 16 + +# Disable cookies (enabled by default) +#COOKIES_ENABLED = False + +# Disable Telnet Console (enabled by default) +#TELNETCONSOLE_ENABLED = False + +# Override the default request headers: +#DEFAULT_REQUEST_HEADERS = { +# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', +# 'Accept-Language': 'en', +#} + +# Enable or disable spider middlewares +# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html +#SPIDER_MIDDLEWARES = { +# 'Bachelorarbeit.middlewares.BachelorarbeitSpiderMiddleware': 543, +#} + +# Enable or disable downloader middlewares +# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html +#DOWNLOADER_MIDDLEWARES = { +# 'Bachelorarbeit.middlewares.BachelorarbeitDownloaderMiddleware': 543, +#} + +# Enable or disable extensions +# See https://docs.scrapy.org/en/latest/topics/extensions.html +#EXTENSIONS = { +# 'scrapy.extensions.telnet.TelnetConsole': None, +#} + +# Configure item pipelines +# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html +#ITEM_PIPELINES = { +# 'Bachelorarbeit.pipelines.BachelorarbeitPipeline': 300, +#} + +# Enable and configure the AutoThrottle extension (disabled by default) +# See https://docs.scrapy.org/en/latest/topics/autothrottle.html +#AUTOTHROTTLE_ENABLED = True +# The initial download delay +#AUTOTHROTTLE_START_DELAY = 5 +# The maximum download delay to be set in case of high latencies +#AUTOTHROTTLE_MAX_DELAY = 60 +# The average number of requests Scrapy should be sending in parallel to +# each remote server +#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0 +# Enable showing throttling stats for every response received: +#AUTOTHROTTLE_DEBUG = False + +# Enable and configure HTTP caching (disabled by default) +# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings +#HTTPCACHE_ENABLED = True +#HTTPCACHE_EXPIRATION_SECS = 0 +#HTTPCACHE_DIR = 'httpcache' +#HTTPCACHE_IGNORE_HTTP_CODES = [] +#HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage' + +# Set settings whose default value is deprecated to a future-proof value +REQUEST_FINGERPRINTER_IMPLEMENTATION = '2.7' +TWISTED_REACTOR = 'twisted.internet.asyncioreactor.AsyncioSelectorReactor' +FEED_EXPORT_ENCODING = 'utf-8' \ No newline at end of file diff --git a/Bachelorarbeit/spiders/__init__.py b/Bachelorarbeit/spiders/__init__.py new file mode 100644 index 0000000..ebd689a --- /dev/null +++ b/Bachelorarbeit/spiders/__init__.py @@ -0,0 +1,4 @@ +# This package will contain the spiders of your Scrapy project +# +# Please refer to the documentation for information on how to create and manage +# your spiders. diff --git a/Bachelorarbeit/spiders/__pycache__/__init__.cpython-39.pyc b/Bachelorarbeit/spiders/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..15077ed610d2f3cf1c83c2fd071952268d9431e9 GIT binary patch literal 158 zcmYe~<>g`kf+DfHJTlVgliVsb`mPJU5hQBrDV2|Bm9ATtG|JU%`%FS8^*Uaz3?7Kcr4eoARh MsvXGi&p^xo0Gr(>d;kCd literal 0 HcmV?d00001 diff --git a/Bachelorarbeit/spiders/__pycache__/project_data.cpython-39.pyc b/Bachelorarbeit/spiders/__pycache__/project_data.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1b6aa5257df9cd10803748bb36892eaa60101b72 GIT binary patch literal 4351 zcmcIn&2Hqz5$@)Yod1zVBaL?SJG*N;p2Vw_lOPDYUhs%lo3 zQ?FMD9PhpSm;28Lg!~O3vWE^2KL?V(1jY!XLt^1o8`4wF(&$81unNgL-O`h*VVTLb zXccz}D=_^9VLB(rrRN2!%;;0nGyVbk$X<`C+WUdu_XbZKA-Ql-nmtO>2l+?1;l!eh zSQ?{Nf$PtSWpMMj$V(UHOR#7$8HpJ$3x8U&D%`lJ^2#NpWS=loCpvjvpv0ej7pAgF zXmb7zI5$|aLs+RptQxNks8we(pOZdiWmb7nwi>L;YA=X2!|JR7*V)fOlhuS7%&O)S z5gcBwVTM77aG^nigZ>TW#Ta@-?641^;Nxfeb}vF#=k-tc@+Q4tyAu>au4 z;D{3U-GF)iU{4jccXp$OGaLrbID5c?Q^)gNE#nuwFHA|k12-WFX-uAL7uqFEDyCv3 zrWXZ9FR8B$NK9-!;RYjMy0-TXeWzzCLykvW2vnp>whab_whhwJ&mBu^38a zcp*QPJx%G75Bs7DAACtw*|y!GBc*MBNxs>2e{%3!h@d=>N6v|Ju=VKR`rL0m%EV*x zVCpd&U9&OzOq4-+6G)oC2yM`L8ZF)O^v0FBE=Ab%K(`n`m`3s*u$UZ^ZSqO`oQCvR zi@`<5;FOoz$Ka$h$kD_Z=zABOedxF+Jw2J7GNmh=(Pygo8-6zCGE~M06SSv^I;d3z zaEq9Qy9q;kRb%2XG5J8YK_+qe5L(fq?(G>|hhGctefVk(=zSoGGs1Z=+9Br})6NS( zI*-^9d)SdWd^jEiw8uEf>27T4oOJQL5x&3GRIHJ8>soikIV+ zcr{*&*V)}aubkigf}Vx&Ptz}q_%7Dy(7Y((^CdmM7vDQBv3u-3dxO3C5^8qxmwszc zU_DS!dl?TMZz!>h!i~>`GD0sLa#eTyP&fk_^5GDqtv=M=p$GNXw#I>A{@5R=Ni; z`;6OQ1N&>Mu@egf4MbTv?rRLzsnj>f8W5(H4j9UMqPl?u@%3!V=u{Y2=1H|#AQjR&gq zbR;-%aLh68>G-!&co8TT2)Ae~kxGt3TzS3r0}0D%7&`4K;Lz*F3Q zl+AM{_ zzE$46ioVr+bTj%R2 zp;he%!sWIjUC-;4l{wj?E929V6CSC;fQQNi28sm6R+$d0W1lH)#H=zl06W4tU=;{W0Nd*yzO z)@ZbNyJ>)5CUhZmuQ!Jsn-4h$9b3h=PXh+OX}GW1_Sx7OPT%Nw71$Pu9|6O>X55uZ zhl=4VEs#l8yU&=SeN~2X#O%HYzx(2(=agz@+JxFuLDHUyMO28Hpz6~e(1n_7+nHo( zAO!oOq`kzZPR;= type the search word -> press on search button ---------------------------------- # +search_input = driver.find_element(By.XPATH, config['example']['search-box']) search_input.send_keys("Universität Duisburg-Essen") time.sleep(0.1) -search_btn = driver.find_element(By.XPATH, config['BMBF']['search-btn']) +search_btn = driver.find_element(By.XPATH, config['example']['search-btn']) search_btn.click() -###############Pagination############### +# ----------------------------- Pagination ---------------------------------- # links = [] isNextDisabeled = False @@ -52,7 +46,7 @@ while not isNextDisabeled: try: - links_config = config['BMBF'] + links_config = config['example'] projects_loading_phase = WebDriverWait(driver,10).until(EC.presence_of_element_located(( By.XPATH, links_config['loading-project-data'] @@ -65,7 +59,7 @@ while not isNextDisabeled: #saving data into json file: df_links = pd.DataFrame({'project_link':links}) - df_links.to_json("project_links_BMBF2.json", orient='records') + df_links.to_json("project_links_example.json", orient='records') try: next_btn = WebDriverWait(driver, 10).until(EC.presence_of_element_located( diff --git a/README.md b/README.md new file mode 100644 index 0000000..078eec2 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +This frame work is designed to retrieve data from different websites with different structure. +currently: +level #1 of abstraction is done by implementing a config file which stores all the xpath of different fields of +the 3 provided websitel inks +level #2 of abstraction is done by implementing a test conditional based on the website's type (js-based or not) + + + + +############################################################################################################################ + +# step 1 +1. open projectlinks directory +2. edit the links_config.ini +3. open links_extractor.py -> url = config['example']['start-url'] (and other relevent fields) +4. once you entered the configured data, links_extractor file will extract the project links by handeling pagination and saves them in project_links_ProjectName.json + +# step 2 +1. to determine wheather we need scrapy or delenium to scrape data from project links, +I passed the first link stored in project_links_ProjectName.json to selenium_or_scrapy.py +2. this file goes through html markup and searches for