Best Python code snippet using selene_python
INSTs.py
Source:INSTs.py
...118# å®è縣å
Œ
±åæ¸é¤¨ ILCCB V OK119def ILCCB(ISBN):120 sheet = ggSheet()121 worksheet = sheet.get_worksheet(0)122 driver = get_chrome()123 gg = webpac_gov_crawler(124 driver,125 'å®è縣å
Œ
±åæ¸é¤¨',126 'https://webpac.ilccb.gov.tw/',127 ISBN128 )129 driver.close()130 worksheet.append_rows(gg.values.tolist())131 return gg132# æ¡åå¸ç«åæ¸é¤¨ TYPL V OK133def TYPL(ISBN):134 sheet = ggSheet()135 worksheet = sheet.get_worksheet(0)136 driver = get_chrome()137 gg = webpac_gov_crawler(138 driver,139 'æ¡åå¸ç«åæ¸é¤¨',140 'https://webpac.typl.gov.tw/',141 ISBN142 )143 driver.close()144 worksheet.append_rows(gg.values.tolist())145 return gg146# é«éå¸ç«åæ¸é¤¨ KSML V OK147def KSML(ISBN):148 sheet = ggSheet()149 worksheet = sheet.get_worksheet(0)150 driver = get_chrome()151 gg = webpac_gov_crawler(152 driver,153 'é«éå¸ç«åæ¸é¤¨',154 'https://webpacx.ksml.edu.tw/',155 ISBN156 )157 driver.close()158 worksheet.append_rows(gg.values.tolist())159 return gg160# å±æ±ç¸£å
Œ
±åæ¸é¤¨ PTPL V OK161def PTPL(ISBN):162 sheet = ggSheet()163 worksheet = sheet.get_worksheet(0)164 driver = get_chrome()165 gg = webpac_gov_crawler(166 driver,167 'å±æ±ç¸£å
Œ
±åæ¸é¤¨',168 'https://library.pthg.gov.tw/',169 ISBN170 )171 driver.close()172 worksheet.append_rows(gg.values.tolist())173 return gg174# è±è®ç¸£å
Œ
±åæ¸é¤¨ HLPL V175def HLPL(ISBN):176 sheet = ggSheet()177 worksheet = sheet.get_worksheet(0)178 driver = get_chrome()179 gg = webpac_gov_crawler(180 driver,181 'è±è®ç¸£å
Œ
±åæ¸é¤¨',182 'https://center.hccc.gov.tw/',183 ISBN184 )185 driver.close()186 worksheet.append_rows(gg.values.tolist())187 return gg188# æ¾æ¹ç¸£å
Œ
±åæ¸é¤¨ PHPL V189def PHPL(ISBN):190 sheet = ggSheet()191 worksheet = sheet.get_worksheet(0)192 driver = get_chrome()193 gg = webpac_gov_crawler(194 driver,195 'æ¾æ¹ç¸£å
Œ
±åæ¸é¤¨',196 'https://webpac.phlib.nat.gov.tw/',197 ISBN198 )199 driver.close()200 worksheet.append_rows(gg.values.tolist())201 return gg202# åç«é²æç§æå¤§å¸ NYUST V203def NYUST(ISBN):204 sheet = ggSheet()205 worksheet = sheet.get_worksheet(0)206 driver = get_chrome()207 gg = webpac_gov_crawler(208 driver,209 'åç«é²æç§æ大å¸',210 'https://www.libwebpac.yuntech.edu.tw/',211 ISBN212 )213 driver.close()214 worksheet.append_rows(gg.values.tolist())215 return gg216# å家é»å½±åè¦è½æåä¸å¿ TFAI V217def TFAI(ISBN):218 sheet = ggSheet()219 worksheet = sheet.get_worksheet(0)220 driver = get_chrome()221 gg = webpac_gov_crawler(222 driver,223 'å家é»å½±åè¦è½æåä¸å¿',224 'https://lib.tfi.org.tw/',225 ISBN226 )227 driver.close()228 worksheet.append_rows(gg.values.tolist())229 return gg230# -----------------------------------------jspç³»å-----------------------------------------------------231# webpac_jsp_crawler()232# ä½å
|ç¶åå¸é¢|å®å¤§|ä¸è¯|ååºç£|å®åå¾·é|åè¥|èºåå¸|èºè大|åå¸å¤§|åé«|åå大|æ°ç«¹å¸|æ°ç«¹ç¸£|èæ 縣233# è²é|ä»å¾·é«å°|æ¯æ|è´ç|è¬è½|å¥è¡|ææ°|空大|ä¸åç§å¤§|ä¸æ大|èºé«|æ±æµ·|éå®|åå
|彰師234# é²æ縣|å義å¸|å義縣|åè¯|é æ±|æ£ä¿®|ç¾å|èºæ±|èºæ±ç¸£|éé|éé縣235# ä½å
å¤§å¸ FGU V236def FGU(ISBN):237 sheet = ggSheet()238 worksheet = sheet.get_worksheet(0)239 driver = get_chrome()240 gg = webpac_jsp_crawler(241 driver,242 'ä½å
大å¸',243 "http://libils.fgu.edu.tw/webpacIndex.jsp",244 ISBN245 )246 driver.close()247 worksheet.append_rows(gg.values.tolist())248 return gg249# ç¶å管çæ¨å¥åº·å¸é¢ CKU V250def CKU(ISBN):251 sheet = ggSheet()252 worksheet = sheet.get_worksheet(0)253 driver = get_chrome()254 gg = webpac_jsp_crawler(255 driver,256 'ç¶å管çæ¨å¥åº·å¸é¢',257 "http://203.64.136.248/webpacIndex.jsp",258 ISBN259 )260 driver.close()261 worksheet.append_rows(gg.values.tolist())262 return gg263# åç«å®èå¤§å¸ NIU V264def NIU(ISBN):265 sheet = ggSheet()266 worksheet = sheet.get_worksheet(0)267 driver = get_chrome()268 gg = webpac_jsp_crawler(269 driver,270 'åç«å®è大å¸',271 "https://lib.niu.edu.tw/webpacIndex.jsp",272 ISBN273 )274 driver.close()275 worksheet.append_rows(gg.values.tolist())276 return gg277# ä¸è¯ç§æå¤§å¸ CUST V278def CUST(ISBN):279 sheet = ggSheet()280 worksheet = sheet.get_worksheet(0)281 driver = get_chrome()282 gg = webpac_jsp_crawler(283 driver,284 'ä¸è¯ç§æ大å¸',285 "http://192.192.231.232/bookDetail.do?id=260965&nowid=3&resid=188809854",286 ISBN287 )288 driver.close()289 worksheet.append_rows(gg.values.tolist())290 return gg291# èºååºç£å¸é¢ CCT V292def CCT(ISBN):293 sheet = ggSheet()294 worksheet = sheet.get_worksheet(0)295 driver = get_chrome()296 gg = webpac_jsp_crawler(297 driver,298 'èºååºç£å¸é¢',299 "http://webpac.cct.edu.tw/webpacIndex.jsp",300 ISBN301 )302 driver.close()303 worksheet.append_rows(gg.values.tolist())304 return gg305# å®åå¾·éç§æå¤§å¸ HDUT V306def HDUT(ISBN):307 sheet = ggSheet()308 worksheet = sheet.get_worksheet(0)309 driver = get_chrome()310 gg = webpac_jsp_crawler(311 driver,312 'å®åå¾·éç§æ大å¸',313 "http://210.60.142.23/webpacIndex.jsp",314 ISBN315 )316 driver.close()317 worksheet.append_rows(gg.values.tolist())318 return gg319# ååè¥çå¤§å¸ CNU V320def CNU(ISBN):321 sheet = ggSheet()322 worksheet = sheet.get_worksheet(0)323 driver = get_chrome()324 gg = webpac_jsp_crawler(325 driver,326 'ååè¥ç大å¸',327 "https://webpac.cnu.edu.tw/webpacIndex.jsp",328 ISBN329 )330 driver.close()331 worksheet.append_rows(gg.values.tolist())332 return gg333# èºåå¸ç«åæ¸é¤¨ TPML V334def TPML(ISBN):335 sheet = ggSheet()336 worksheet = sheet.get_worksheet(0)337 driver = get_chrome()338 gg = webpac_jsp_crawler(339 driver,340 'èºåå¸ç«åæ¸é¤¨',341 'https://book.tpml.edu.tw/webpac/webpacIndex.jsp',342 ISBN343 )344 driver.close()345 worksheet.append_rows(gg.values.tolist())346 return gg347# åç«èºç£èè¡å¤§å¸ NTUA V348def NTUA(ISBN):349 sheet = ggSheet()350 worksheet = sheet.get_worksheet(0)351 driver = get_chrome()352 gg = webpac_jsp_crawler(353 driver,354 'åç«èºç£èè¡å¤§å¸',355 'http://webpac.ntua.edu.tw/webpacIndex.jsp',356 ISBN357 )358 driver.close()359 worksheet.append_rows(gg.values.tolist())360 return gg361# èºåå¸ç«å¤§å¸ UTaipei V362def UTaipei(ISBN):363 sheet = ggSheet()364 worksheet = sheet.get_worksheet(0)365 driver = get_chrome()366 gg = webpac_jsp_crawler(367 driver,368 'èºåå¸ç«å¤§å¸',369 'http://lib.utaipei.edu.tw/webpac/webpacIndex.jsp',370 ISBN371 )372 driver.close()373 worksheet.append_rows(gg.values.tolist())374 return gg375# åç«èºåç§æå¤§å¸ NTUT V376def NTUT(ISBN):377 sheet = ggSheet()378 worksheet = sheet.get_worksheet(0)379 driver = get_chrome()380 gg = webpac_jsp_crawler(381 driver,382 'åç«èºåç§æ大å¸',383 'https://libholding.ntut.edu.tw/webpacIndex.jsp',384 ISBN385 )386 driver.close()387 worksheet.append_rows(gg.values.tolist())388 return gg389# èºåé«å¸å¤§å¸ TMU V390def TMU(ISBN):391 sheet = ggSheet()392 worksheet = sheet.get_worksheet(0)393 driver = get_chrome()394 gg = webpac_jsp_crawler(395 driver,396 'èºåé«å¸å¤§å¸',397 'https://libelis.tmu.edu.tw/webpacIndex.jsp',398 ISBN399 )400 driver.close()401 worksheet.append_rows(gg.values.tolist())402 return gg403# åç«èºååæ¥å¤§å¸ NTUB V404def NTUB(ISBN):405 sheet = ggSheet()406 worksheet = sheet.get_worksheet(0)407 driver = get_chrome()408 gg = webpac_jsp_crawler(409 driver,410 'åç«èºååæ¥å¤§å¸',411 'http://webpac.ntub.edu.tw/webpacIndex.jsp',412 ISBN413 )414 driver.close()415 worksheet.append_rows(gg.values.tolist())416 return gg417# æ¯æç§æå¤§å¸ JUST V418def JUST(ISBN):419 sheet = ggSheet()420 worksheet = sheet.get_worksheet(0)421 driver = get_chrome()422 gg = webpac_jsp_crawler(423 driver,424 'æ¯æç§æ大å¸',425 'https://jinwenlib.just.edu.tw/webpacIndex.jsp',426 ISBN427 )428 driver.close()429 worksheet.append_rows(gg.values.tolist())430 return gg431# è´çç§æå¤§å¸ CLUT V432def CLUT(ISBN):433 sheet = ggSheet()434 worksheet = sheet.get_worksheet(0)435 driver = get_chrome()436 gg = webpac_jsp_crawler(437 driver,438 'è´çç§æ大å¸',439 'http://hylib.chihlee.edu.tw/webpacIndex.jsp',440 ISBN441 )442 driver.close()443 worksheet.append_rows(gg.values.tolist())444 return gg445# è¬è½ç§æå¤§å¸ VNU V446def VNU(ISBN):447 sheet = ggSheet()448 worksheet = sheet.get_worksheet(0)449 driver = get_chrome()450 gg = webpac_jsp_crawler(451 driver,452 'è¬è½ç§æ大å¸',453 'http://webpac.lib.vnu.edu.tw/webpacIndex.jsp',454 ISBN455 )456 driver.close()457 worksheet.append_rows(gg.values.tolist())458 return gg459# å¥è¡ç§æå¤§å¸ UCH V460def UCH(ISBN):461 sheet = ggSheet()462 worksheet = sheet.get_worksheet(0)463 driver = get_chrome()464 gg = webpac_jsp_crawler(465 driver,466 'å¥è¡ç§æ大å¸',467 'https://library.uch.edu.tw/webpacIndex.jsp',468 ISBN469 )470 driver.close()471 worksheet.append_rows(gg.values.tolist())472 return gg473# ææ°ç§æå¤§å¸ MUST V474def MUST(ISBN):475 sheet = ggSheet()476 worksheet = sheet.get_worksheet(0)477 driver = get_chrome()478 gg = webpac_jsp_crawler(479 driver,480 'ææ°ç§æ大å¸',481 'https://hylib.lib.must.edu.tw/webpacIndex.jsp',482 ISBN483 )484 driver.close()485 worksheet.append_rows(gg.values.tolist())486 return gg487# åç«ç©ºä¸å¤§å¸ NOU V488def NOU(ISBN):489 sheet = ggSheet()490 worksheet = sheet.get_worksheet(0)491 driver = get_chrome()492 gg = webpac_jsp_crawler(493 driver,494 'åç«ç©ºä¸å¤§å¸',495 'https://hyweblib.nou.edu.tw/webpac/webpacIndex.jsp',496 ISBN497 )498 driver.close()499 worksheet.append_rows(gg.values.tolist())500 return gg501# æ°ç«¹å¸ç«åæ¸é¤¨ HCLIB V502def HCLIB(ISBN):503 sheet = ggSheet()504 worksheet = sheet.get_worksheet(0)505 driver = get_chrome()506 gg = webpac_jsp_crawler(507 driver,508 'æ°ç«¹å¸ç«åæ¸é¤¨',509 'https://webpac.hcml.gov.tw/webpacIndex.jsp',510 ISBN511 )512 driver.close()513 worksheet.append_rows(gg.values.tolist())514 return gg515# æ°ç«¹ç¸£å
Œ
±åæ¸é¤¨ HCPL V516def HCPL(ISBN):517 sheet = ggSheet()518 worksheet = sheet.get_worksheet(0)519 driver = get_chrome()520 gg = webpac_jsp_crawler(521 driver,522 'æ°ç«¹ç¸£å
Œ
±åæ¸é¤¨',523 'https://book.hchcc.gov.tw/webpacIndex.jsp',524 ISBN525 )526 driver.close()527 worksheet.append_rows(gg.values.tolist())528 return gg529# èæ 縣ç«åæ¸é¤¨ Miaoli V530def Miaoli(ISBN):531 sheet = ggSheet()532 worksheet = sheet.get_worksheet(0)533 driver = get_chrome()534 gg = webpac_jsp_crawler(535 driver,536 'èæ 縣ç«åæ¸é¤¨',537 'https://webpac.miaoli.gov.tw/webpacIndex.jsp',538 ISBN539 )540 driver.close()541 worksheet.append_rows(gg.values.tolist())542 return gg543# è²éç§æå¤§å¸ YDU V544def YDU(ISBN):545 sheet = ggSheet()546 worksheet = sheet.get_worksheet(0)547 driver = get_chrome()548 gg = webpac_jsp_crawler(549 driver,550 'è²éç§æ大å¸',551 'http://120.106.11.155/webpacIndex.jsp',552 ISBN553 )554 driver.close()555 worksheet.append_rows(gg.values.tolist())556 return gg557# ä»å¾·é«è·ç®¡çå°ç§å¸æ ¡ Jente V558def Jente(ISBN):559 sheet = ggSheet()560 worksheet = sheet.get_worksheet(0)561 driver = get_chrome()562 gg = webpac_jsp_crawler(563 driver,564 'ä»å¾·é«è·ç®¡çå°ç§å¸æ ¡',565 'http://libopac.jente.edu.tw/webpacIndex.jsp',566 ISBN567 )568 driver.close()569 worksheet.append_rows(gg.values.tolist())570 return gg571# ä¸åç§æå¤§å¸ CUTE V572def CUTE(ISBN):573 sheet = ggSheet()574 worksheet = sheet.get_worksheet(0)575 driver = get_chrome()576 gg = webpac_jsp_crawler(577 driver,578 'ä¸åç§æ大å¸',579 'https://webpac.cute.edu.tw/webpacIndex.jsp',580 ISBN581 )582 driver.close()583 worksheet.append_rows(gg.values.tolist())584 return gg585# åç«èºä¸æè²å¤§å¸ NTCU V586def NTCU(ISBN):587 sheet = ggSheet()588 worksheet = sheet.get_worksheet(0)589 driver = get_chrome()590 gg = webpac_jsp_crawler(591 driver,592 'åç«èºä¸æè²å¤§å¸',593 'http://webpac.lib.ntcu.edu.tw/webpacIndex.jsp',594 ISBN595 )596 driver.close()597 worksheet.append_rows(gg.values.tolist())598 return gg599# åç«èºç£é«è²éåå¤§å¸ NTUS V600def NTUS(ISBN):601 sheet = ggSheet()602 worksheet = sheet.get_worksheet(0)603 driver = get_chrome()604 gg = webpac_jsp_crawler(605 driver,606 'åç«èºç£é«è²éå大å¸',607 'https://hylib.ntus.edu.tw/webpacIndex.jsp',608 ISBN609 )610 driver.close()611 worksheet.append_rows(gg.values.tolist())612 return gg613# æ±æµ·å¤§å¸ THU V614def THU(ISBN):615 sheet = ggSheet()616 worksheet = sheet.get_worksheet(0)617 driver = get_chrome()618 gg = webpac_jsp_crawler(619 driver,620 'æ±æµ·å¤§å¸',621 'https://webpac.lib.thu.edu.tw/webpacIndex.jsp',622 ISBN623 )624 driver.close()625 worksheet.append_rows(gg.values.tolist())626 return gg627# éå®å¤§å¸ PU V628def PU(ISBN):629 sheet = ggSheet()630 worksheet = sheet.get_worksheet(0)631 driver = get_chrome()632 gg = webpac_jsp_crawler(633 driver,634 'éå®å¤§å¸',635 'http://webpac.lib.pu.edu.tw/webpac/webpacIndex.jsp',636 ISBN637 )638 driver.close()639 worksheet.append_rows(gg.values.tolist())640 return gg641# åå
ç§æå¤§å¸ OCU V642def OCU(ISBN):643 sheet = ggSheet()644 worksheet = sheet.get_worksheet(0)645 driver = get_chrome()646 gg = webpac_jsp_crawler(647 driver,648 'åå
ç§æ大å¸',649 'http://lib.webpac.ocu.edu.tw/webpacIndex.jsp',650 ISBN651 )652 driver.close()653 worksheet.append_rows(gg.values.tolist())654 return gg655# åç«å½°å師ç¯å¤§å¸ NCUE V656def NCUE(ISBN):657 sheet = ggSheet()658 worksheet = sheet.get_worksheet(0)659 driver = get_chrome()660 gg = webpac_jsp_crawler(661 driver,662 'åç«å½°å師ç¯å¤§å¸',663 'https://book.ncue.edu.tw/webpacIndex.jsp',664 ISBN665 )666 driver.close()667 worksheet.append_rows(gg.values.tolist())668 return gg669# é²æ縣å
Œ
±åæ¸é¤¨ YLCCB V670def YLCCB(ISBN):671 sheet = ggSheet()672 worksheet = sheet.get_worksheet(0)673 driver = get_chrome()674 gg = webpac_jsp_crawler(675 driver,676 'é²æ縣å
Œ
±åæ¸é¤¨',677 'http://library.ylccb.gov.tw/webpacIndex.jsp',678 ISBN679 )680 driver.close()681 worksheet.append_rows(gg.values.tolist())682 return gg683# å義å¸ç«åæ¸é¤¨ CYLIB X(é²ä¸å»...)684def CYLIB(ISBN):685 sheet = ggSheet()686 worksheet = sheet.get_worksheet(0)687 driver = get_chrome()688 gg = webpac_jsp_crawler(689 driver,690 'å義å¸ç«åæ¸é¤¨',691 'http://library.cabcy.gov.tw/webpacIndex.jsp',692 ISBN693 )694 driver.close()695 worksheet.append_rows(gg.values.tolist())696 return gg697# å義縣åæ¸é¤¨ CYCPL V698def CYCPL(ISBN):699 sheet = ggSheet()700 worksheet = sheet.get_worksheet(0)701 driver = get_chrome()702 gg = webpac_jsp_crawler(703 driver,704 'å義縣åæ¸é¤¨',705 'https://www.cycab.gov.tw/webpacIndex.jsp',706 ISBN707 )708 driver.close()709 worksheet.append_rows(gg.values.tolist())710 return gg711# åè¯å¤§å¸ NHU V712def NHU(ISBN):713 sheet = ggSheet()714 worksheet = sheet.get_worksheet(0)715 driver = get_chrome()716 gg = webpac_jsp_crawler(717 driver,718 'åè¯å¤§å¸',719 'http://hylib.nhu.edu.tw//webpacIndex.jsp',720 ISBN721 )722 driver.close()723 worksheet.append_rows(gg.values.tolist())724 return gg725# é æ±ç§æå¤§å¸ FEU V726def FEU(ISBN):727 sheet = ggSheet()728 worksheet = sheet.get_worksheet(0)729 driver = get_chrome()730 gg = webpac_jsp_crawler(731 driver,732 'é æ±ç§æ大å¸',733 'http://hy.lib.feu.edu.tw/webpacIndex.jsp',734 ISBN735 )736 driver.close()737 worksheet.append_rows(gg.values.tolist())738 return gg739# æ£ä¿®ç§æå¤§å¸ CSU V740def CSU(ISBN):741 sheet = ggSheet()742 worksheet = sheet.get_worksheet(0)743 driver = get_chrome()744 gg = webpac_jsp_crawler(745 driver,746 'æ£ä¿®ç§æ大å¸',747 'https://webpac2.csu.edu.tw/webpacIndex.jsp',748 ISBN749 )750 driver.close()751 worksheet.append_rows(gg.values.tolist())752 return gg753# ç¾åç§æå¤§å¸ Meiho V754def Meiho(ISBN):755 sheet = ggSheet()756 worksheet = sheet.get_worksheet(0)757 driver = get_chrome()758 gg = webpac_jsp_crawler(759 driver,760 'ç¾åç§æ大å¸',761 'http://webpac.meiho.edu.tw/webpacIndex.jsp',762 ISBN763 )764 driver.close()765 worksheet.append_rows(gg.values.tolist())766 return gg767# åç«èºæ±å¤§å¸ NTTU V768def NTTU(ISBN):769 sheet = ggSheet()770 worksheet = sheet.get_worksheet(0)771 driver = get_chrome()772 gg = webpac_jsp_crawler(773 driver,774 'åç«èºæ±å¤§å¸',775 'http://hylib.lib.nttu.edu.tw/webpac/webpacIndex.jsp',776 ISBN777 )778 driver.close()779 worksheet.append_rows(gg.values.tolist())780 return gg781# èºæ±ç¸£ç«åæ¸é¤¨ TTCPL V782def TTCPL(ISBN):783 sheet = ggSheet()784 worksheet = sheet.get_worksheet(0)785 driver = get_chrome()786 gg = webpac_jsp_crawler(787 driver,788 'èºæ±ç¸£ç«åæ¸é¤¨',789 'http://library.ccl.ttct.edu.tw/webpacIndex.jsp',790 ISBN791 )792 driver.close()793 worksheet.append_rows(gg.values.tolist())794 return gg795# åç«ééå¤§å¸ NQU V796def NQU(ISBN):797 sheet = ggSheet()798 worksheet = sheet.get_worksheet(0)799 driver = get_chrome()800 gg = webpac_jsp_crawler(801 driver,802 'åç«éé大å¸',803 'https://lib.nqu.edu.tw/webpacIndex.jsp',804 ISBN805 )806 driver.close()807 worksheet.append_rows(gg.values.tolist())808 return gg809# éé縣ç«åæ¸é¤¨ KMCPL V810def KMCPL(ISBN):811 sheet = ggSheet()812 worksheet = sheet.get_worksheet(0)813 driver = get_chrome()814 gg = webpac_jsp_crawler(815 driver,816 'éé縣ç«åæ¸é¤¨',817 'http://library.kmccc.edu.tw/webpacIndex.jsp',818 ISBN819 )820 driver.close()821 worksheet.append_rows(gg.values.tolist())822 return gg823# ------------------------------------æç°¡å®çé£ç¨®------------------------------------------824# easy_crawler()825# 海大|å°ç§å¤§|å°å¸«å¤§|ä¸å|é¢ç²|æé½|ä¸å±±|é«å¸«|æè»|大ä»|ä¸å¤®826# åç«èºç£æµ·æ´å¤§å¸ NTOU V827def NTOU(ISBN):828 try:829 scope = ['https://www.googleapis.com/auth/spreadsheets']830 creds = Credentials.from_service_account_file(831 "json_files_for_robot/books-319701-17701ae5510b.json", scopes=scope)832 gs = gspread.authorize(creds)833 sheet = gs.open_by_url(834 'https://docs.google.com/spreadsheets/d/17fJuHSGHnjHbyKJzTgzKpp1pe2J6sirK5QVjg2-8fFo/edit#gid=0')835 worksheet = sheet.get_worksheet(0)836 driver = webdriver.Chrome(837 options=my_options, desired_capabilities=my_capabilities)838 gg = easy_crawler(839 driver,840 'åç«èºç£æµ·æ´å¤§å¸',841 'https://ocean.ntou.edu.tw/search*cht/i?SEARCH=',842 ISBN843 )844 driver.close()845 worksheet.append_rows(gg.values.tolist())846 except Exception as e:847 print(f'å¨ NTOU()ï¼ç¼çé¯èª¤ï¼ã{e}ã')848 return849 else:850 return gg851# åç«èºç£ç§æå¤§å¸ NTUST V852def NTUST(ISBN):853 sheet = ggSheet()854 worksheet = sheet.get_worksheet(0)855 driver = get_chrome()856 gg = easy_crawler(857 driver,858 'åç«èºç£ç§æ大å¸',859 "https://sierra.lib.ntust.edu.tw/search*cht/i?SEARCH=",860 ISBN861 )862 driver.close()863 worksheet.append_rows(gg.values.tolist())864 return gg865# åç«èºç£å¸«ç¯å¤§å¸ NTNU V866def NTNU(ISBN):867 sheet = ggSheet()868 worksheet = sheet.get_worksheet(0)869 driver = get_chrome()870 gg = easy_crawler(871 driver,872 'åç«èºç£å¸«ç¯å¤§å¸',873 "https://opac.lib.ntnu.edu.tw/search*cht/i?SEARCH=",874 ISBN875 )876 driver.close()877 worksheet.append_rows(gg.values.tolist())878 return gg879# ä¸åå¤§å¸ CYCU V880def CYCU(ISBN):881 sheet = ggSheet()882 worksheet = sheet.get_worksheet(0)883 driver = get_chrome()884 gg = easy_crawler(885 driver,886 'ä¸å大å¸',887 "http://cylis.lib.cycu.edu.tw/search*cht/i",888 ISBN889 )890 driver.close()891 worksheet.append_rows(gg.values.tolist())892 return gg893# é¢ç²å¤§å¸ FCU V894def FCU(ISBN):895 sheet = ggSheet()896 worksheet = sheet.get_worksheet(0)897 driver = get_chrome()898 gg = easy_crawler(899 driver,900 'é¢ç²å¤§å¸',901 "https://innopac.lib.fcu.edu.tw/search*cht/i",902 ISBN903 )904 driver.close()905 worksheet.append_rows(gg.values.tolist())906 return gg907# æé½ç§æå¤§å¸ CYUT V908def CYUT(ISBN):909 sheet = ggSheet()910 worksheet = sheet.get_worksheet(0)911 driver = get_chrome()912 gg = easy_crawler(913 driver,914 'æé½ç§æ大å¸',915 "https://millennium.lib.cyut.edu.tw/search*cht/i",916 ISBN917 )918 driver.close()919 worksheet.append_rows(gg.values.tolist())920 return gg921# åç«ä¸å±±å¤§å¸ NSYSU V922def NSYSU(ISBN):923 sheet = ggSheet()924 worksheet = sheet.get_worksheet(0)925 driver = get_chrome()926 gg = easy_crawler(927 driver,928 'åç«ä¸å±±å¤§å¸',929 "https://dec.lib.nsysu.edu.tw/search*cht/i",930 ISBN931 )932 driver.close()933 worksheet.append_rows(gg.values.tolist())934 return gg935# åç«é«é師ç¯å¤§å¸ NKNU V936def NKNU(ISBN):937 sheet = ggSheet()938 worksheet = sheet.get_worksheet(0)939 driver = get_chrome()940 gg = easy_crawler(941 driver,942 'åç«é«é師ç¯å¤§å¸',943 "https://nknulib.nknu.edu.tw/search*cht/i",944 ISBN945 )946 driver.close()947 worksheet.append_rows(gg.values.tolist())948 return gg949# æè»å¤èªå¤§å¸ WZU V950def WZU(ISBN):951 sheet = ggSheet()952 worksheet = sheet.get_worksheet(0)953 driver = get_chrome()954 gg = easy_crawler(955 driver,956 'æè»å¤èªå¤§å¸',957 "https://libpac.wzu.edu.tw/search*cht/i",958 ISBN959 )960 driver.close()961 worksheet.append_rows(gg.values.tolist())962 return gg963# 大ä»ç§æå¤§å¸ Tajen V964def Tajen(ISBN):965 sheet = ggSheet()966 worksheet = sheet.get_worksheet(0)967 driver = get_chrome()968 gg = easy_crawler(969 driver,970 '大ä»ç§æ大å¸',971 "http://lib.tajen.edu.tw/search*cht/i",972 ISBN973 )974 driver.close()975 worksheet.append_rows(gg.values.tolist())976 return gg977# åç«ä¸å¤®å¤§å¸ NCU V978def NCU(ISBN):979 sheet = ggSheet()980 worksheet = sheet.get_worksheet(0)981 driver = get_chrome()982 gg = easy_crawler(983 driver,984 'åç«ä¸å¤®å¤§å¸',985 "https://opac.lib.ncu.edu.tw/search*cht/i",986 ISBN987 )988 driver.close()989 worksheet.append_rows(gg.values.tolist())990 return gg991# -------------------------------------æ¹ç?------------------------------------------992# webpac_pro_crawler()993# ä¸ç é¢|æå|è¼ä»|é½äº¤å¤§994# ä¸å¤®ç ç©¶é¢ SINICA V995def SINICA(ISBN):996 sheet = ggSheet()997 worksheet = sheet.get_worksheet(0)998 driver = get_chrome()999 gg = webpac_pro_crawler(1000 driver,1001 'ä¸å¤®ç 究é¢',1002 "https://las.sinica.edu.tw/*cht",1003 ISBN1004 )1005 driver.close()1006 worksheet.append_rows(gg.values.tolist())1007 return gg1008# ä¸åæåå¤§å¸ PCCU V1009def PCCU(ISBN):1010 sheet = ggSheet()1011 worksheet = sheet.get_worksheet(0)1012 driver = get_chrome()1013 gg = webpac_pro_crawler(1014 driver,1015 'ä¸åæå大å¸',1016 "https://webpac.pccu.edu.tw/*cht",1017 ISBN1018 )1019 driver.close()1020 worksheet.append_rows(gg.values.tolist())1021 return gg1022# è¼ä»å¤§å¸ FJU V1023def FJU(ISBN):1024 sheet = ggSheet()1025 worksheet = sheet.get_worksheet(0)1026 driver = get_chrome()1027 gg = webpac_pro_crawler(1028 driver,1029 'è¼ä»å¤§å¸',1030 "https://library.lib.fju.edu.tw/",1031 ISBN1032 )1033 driver.close()1034 worksheet.append_rows(gg.values.tolist())1035 return gg1036# åç«é½æ交éå¤§å¸ NYCU V1037def NYCU(ISBN):1038 sheet = ggSheet()1039 worksheet = sheet.get_worksheet(0)1040 driver = get_chrome()1041 gg = webpac_pro_crawler(1042 driver,1043 'åç«é½æ交é大å¸',1044 "https://library.ym.edu.tw/screens/opacmenu_cht_s7.html",1045 ISBN1046 )1047 driver.close()1048 worksheet.append_rows(gg.values.tolist())1049 return gg1050# åç«æåå¤§å¸ NYCU V1051def NCKU(ISBN):1052 sheet = ggSheet()1053 worksheet = sheet.get_worksheet(0)1054 driver = get_chrome()1055 gg = webpac_pro_crawler(1056 driver,1057 'åç«æå大å¸',1058 "https://weblis.lib.ncku.edu.tw/",1059 ISBN1060 )1061 driver.close()1062 worksheet.append_rows(gg.values.tolist())1063 return gg1064# -----------------------------------ajax_page------------------------------------------------1065# webpac_ajax_crawler()1066# æ°åå¸|é«ç©ºå¤§|å±å¤§1067# æ°åå¸ç«åæ¸é¤¨ NTPC V1068def NTPC(ISBN):1069 sheet = ggSheet()1070 worksheet = sheet.get_worksheet(0)1071 driver = get_chrome()1072 gg = webpac_ajax_crawler(1073 driver,1074 'æ°åå¸ç«åæ¸é¤¨',1075 "https://webpac.tphcc.gov.tw/webpac/search.cfm",1076 ISBN1077 )1078 driver.close()1079 worksheet.append_rows(gg.values.tolist())1080 return gg1081# é«éå¸ç«ç©ºä¸å¤§å¸ OUK V1082def OUK(ISBN):1083 sheet = ggSheet()1084 worksheet = sheet.get_worksheet(0)1085 driver = get_chrome()1086 gg = webpac_ajax_crawler(1087 driver,1088 'é«éå¸ç«ç©ºä¸å¤§å¸',1089 "https://webpac.ouk.edu.tw/webpac/search.cfm",1090 ISBN1091 )1092 driver.close()1093 worksheet.append_rows(gg.values.tolist())1094 return gg1095# åç«å±æ±å¤§å¸ NPTU V1096def NPTU(ISBN):1097 sheet = ggSheet()1098 worksheet = sheet.get_worksheet(0)1099 driver = get_chrome()1100 gg = webpac_ajax_crawler(1101 driver,1102 'åç«å±æ±å¤§å¸',1103 "https://webpac.nptu.edu.tw/webpac/search.cfm",1104 ISBN1105 )1106 driver.close()1107 worksheet.append_rows(gg.values.tolist())1108 return gg1109# -----------------------------------ä¸ç´åiframe------------------------------------------------1110# webpac_aspx_crawler()1111# 樹德|é¦åº|å´å±±|å¼å
|修平|è¯å¤|çç|實è¸|è¯æ¢µ|è¯å1112# 樹德ç§æå¤§å¸ STU V1113def STU(ISBN):1114 sheet = ggSheet()1115 worksheet = sheet.get_worksheet(0)1116 driver = get_chrome()1117 gg = webpac_aspx_crawler(1118 driver,1119 '樹德ç§æ大å¸',1120 "https://webpac.stu.edu.tw/webopac/",1121 ISBN1122 )1123 driver.close()1124 worksheet.append_rows(gg.values.tolist())1125 return gg1126# å°ç£é¦åºå¤§å¸ TSU V1127def TSU(ISBN):1128 sheet = ggSheet()1129 worksheet = sheet.get_worksheet(0)1130 driver = get_chrome()1131 gg = webpac_aspx_crawler(1132 driver,1133 'å°ç£é¦åºå¤§å¸',1134 "http://120.114.1.19/webopac/Jycx.aspx?dc=1&fc=1&n=7",1135 ISBN1136 )1137 driver.close()1138 worksheet.append_rows(gg.values.tolist())1139 return gg1140# å´å±±ç§æå¤§å¸ KSU V1141def KSU(ISBN):1142 sheet = ggSheet()1143 worksheet = sheet.get_worksheet(0)1144 driver = get_chrome()1145 gg = webpac_aspx_crawler(1146 driver,1147 'å´å±±ç§æ大å¸',1148 "https://weblis.lib.ksu.edu.tw/webopac/",1149 ISBN1150 )1151 driver.close()1152 worksheet.append_rows(gg.values.tolist())1153 return gg1154# å¼å
ç§æå¤§å¸ HKU V1155def HKU(ISBN):1156 sheet = ggSheet()1157 worksheet = sheet.get_worksheet(0)1158 driver = get_chrome()1159 gg = webpac_aspx_crawler(1160 driver,1161 'å¼å
ç§æ大å¸',1162 "https://webpac.hk.edu.tw/webopac/",1163 ISBN1164 )1165 driver.close()1166 worksheet.append_rows(gg.values.tolist())1167 return gg1168# 修平ç§æå¤§å¸ HUST V1169def HUST(ISBN):1170 sheet = ggSheet()1171 worksheet = sheet.get_worksheet(0)1172 driver = get_chrome()1173 gg = webpac_aspx_crawler(1174 driver,1175 '修平ç§æ大å¸',1176 "http://163.17.79.108/webopac/",1177 ISBN1178 )1179 driver.close()1180 worksheet.append_rows(gg.values.tolist())1181 return gg1182# è¯å¤ç§æå¤§å¸ HWH V1183def HWH(ISBN):1184 sheet = ggSheet()1185 worksheet = sheet.get_worksheet(0)1186 driver = get_chrome()1187 gg = webpac_aspx_crawler(1188 driver,1189 'è¯å¤ç§æ大å¸',1190 "http://webopac.lib.hwh.edu.tw/webopac/",1191 ISBN1192 )1193 driver.close()1194 worksheet.append_rows(gg.values.tolist())1195 return gg1196# ççå¤§å¸ AU V1197def AU(ISBN):1198 try:1199 print('ï¼./INSTs.pyï¼å·è¡éè¡1')1200 scope = ['https://www.googleapis.com/auth/spreadsheets']1201 print('ï¼./INSTs.pyï¼å·è¡éè¡2')1202 creds = Credentials.from_service_account_file(1203 "json_files_for_robot/books-319701-17701ae5510b.json", scopes=scope)1204 print('ï¼./INSTs.pyï¼å·è¡éè¡3')1205 gs = gspread.authorize(creds)1206 print('ï¼./INSTs.pyï¼å·è¡éè¡4')1207 sheet = gs.open_by_url(1208 'https://docs.google.com/spreadsheets/d/17fJuHSGHnjHbyKJzTgzKpp1pe2J6sirK5QVjg2-8fFo/edit#gid=0')1209 print('ï¼./INSTs.pyï¼å·è¡éè¡5')1210 worksheet = sheet.get_worksheet(0)1211 print('ï¼./INSTs.pyï¼å·è¡éè¡6')1212 print('ï¼./INSTs.pyï¼å·è¡éè¡7')1213 driver = webdriver.Chrome(1214 options=my_options, desired_capabilities=my_capabilities)1215 print('ï¼./INSTs.pyï¼å·è¡éè¡8')1216 print('ï¼./INSTs.pyï¼å·è¡éè¡9')1217 gg = webpac_aspx_crawler(1218 driver,1219 'çç大å¸',1220 "https://lib.au.edu.tw/webopac/",1221 ISBN1222 )1223 driver.close()1224 worksheet.append_rows(gg.values.tolist())1225 except Exception as e:1226 print(f'å½å¼ AU() ç¼çé¯èª¤ï¼{e}')1227 return1228 else:1229 return gg1230# 實è¸å¤§å¸ USC V1231def USC(ISBN):1232 sheet = ggSheet()1233 worksheet = sheet.get_worksheet(0)1234 driver = get_chrome()1235 gg = webpac_aspx_crawler(1236 driver,1237 '實è¸å¤§å¸',1238 "https://webopac.usc.edu.tw/webopac/",1239 ISBN1240 )1241 driver.close()1242 worksheet.append_rows(gg.values.tolist())1243 return gg1244# è¯æ¢µå¤§å¸ HFU V1245def HFU(ISBN):1246 sheet = ggSheet()1247 worksheet = sheet.get_worksheet(0)1248 driver = get_chrome()1249 gg = webpac_aspx_crawler(1250 driver,1251 'è¯æ¢µå¤§å¸',1252 "http://210.59.113.12/webopac/",1253 ISBN1254 )1255 driver.close()1256 worksheet.append_rows(gg.values.tolist())1257 return gg1258# åç«è¯åå¤§å¸ NUU V1259def NUU(ISBN):1260 sheet = ggSheet()1261 worksheet = sheet.get_worksheet(0)1262 driver = get_chrome()1263 gg = webpac_aspx_crawler(1264 driver,1265 'åç«è¯å大å¸',1266 "http://210.60.171.7/webopac/",1267 ISBN1268 )1269 driver.close()1270 worksheet.append_rows(gg.values.tolist())1271 return gg1272# -----------------------------------æ館èå°å±étable------------------------------------------------1273# uhtbin_crawler()1274# ååè·|大å|åé«å¤§1275# åç«èºåè·çå¥åº·å¤§å¸ NTUNHS V1276def NTUNHS(ISBN):1277 sheet = ggSheet()1278 worksheet = sheet.get_worksheet(0)1279 driver = get_chrome()1280 gg = uhtbin_crawler(1281 driver,1282 'åç«èºåè·çå¥åº·å¤§å¸',1283 "http://140.131.94.8/uhtbin/webcat",1284 ISBN1285 )1286 driver.close()1287 worksheet.append_rows(gg.values.tolist())1288 return gg1289# 大åå¤§å¸ TTU V1290def TTU(ISBN):1291 sheet = ggSheet()1292 worksheet = sheet.get_worksheet(0)1293 driver = get_chrome()1294 gg = uhtbin_crawler(1295 driver,1296 '大å大å¸',1297 "http://140.129.23.14/uhtbin/webcat",1298 ISBN1299 )1300 driver.close()1301 worksheet.append_rows(gg.values.tolist())1302 return gg1303# åç«é«è²å¤§å¸ NTSU V1304def NTSU(ISBN):1305 sheet = ggSheet()1306 worksheet = sheet.get_worksheet(0)1307 driver = get_chrome()1308 gg = uhtbin_crawler(1309 driver,1310 'åç«é«è²å¤§å¸',1311 "http://192.83.181.243/uhtbin/webcat",1312 ISBN1313 )1314 driver.close()1315 worksheet.append_rows(gg.values.tolist())1316 return gg1317# --------------------------------------éå¾æ¸
æ°è«ä¿------------------------------------------------1318# ugly_crawler()1319# é£æ±ç¸£|éå1320def ugly_crawler(driver, org, org_url, ISBN):1321 try:1322 table = []1323 driver.get(org_url)1324 search_ISBN(driver, ISBN, 'ISBN')1325 if wait_for_element_present(driver, 'éæ°æ¥è©¢', by=By.LINK_TEXT):1326 print(f'å¨ã{org}ãæ¾ä¸å°ã{ISBN}ã')1327 return1328 tgt = accurately_find_table_and_read_it(driver, 'table', -2)1329 tgt['åæ¸é¤¨'], tgt['é£çµ'] = org, driver.current_url1330 table.append(tgt)1331 table = organize_columns(table)1332 except Exception as e:1333 print(f'å¨ã{org}ãæå°ã{ISBN}ãæï¼ç¼çé¯èª¤ï¼é¯èª¤è¨æ¯çºï¼ã{e}ãï¼')1334 return1335 else:1336 return table1337# é£æ±ç¸£å
Œ
±åæ¸é¤¨ Matsu V1338def Matsu(ISBN):1339 sheet = ggSheet()1340 worksheet = sheet.get_worksheet(0)1341 driver = get_chrome()1342 gg = ugly_crawler(1343 driver,1344 'é£æ±ç¸£å
Œ
±åæ¸é¤¨',1345 "http://210.63.206.76/Webpac2/msearch.dll/",1346 ISBN1347 )1348 driver.close()1349 worksheet.append_rows(gg.values.tolist())1350 return gg1351# éåå¤§å¸ KNU V1352def KNU(ISBN):1353 sheet = ggSheet()1354 worksheet = sheet.get_worksheet(0)1355 driver = get_chrome()1356 gg = ugly_crawler(1357 driver,1358 'éå大å¸',1359 "http://www.lib.knu.edu.tw/Webpac2/msearch.dll/",1360 ISBN1361 )1362 driver.close()1363 worksheet.append_rows(gg.values.tolist())1364 return gg1365# ---------------------------------------èèæ¾å¤§é¡------------------------------------------------1366# toread_crawler()1367# æ±å°|éå¾|å½°å縣|é«é«|èç§|èç´ç¿°|æ±å|æ°ç|å´ä»|å
å¹1368# ------------åç«èºæ±å°ç§å¸æ ¡-------------1369def NTC(ISBN):1370 sheet = ggSheet()1371 worksheet = sheet.get_worksheet(0)1372 driver = get_chrome()1373 gg = toread_crawler(1374 driver,1375 'åç«èºæ±å°ç§å¸æ ¡',1376 'https://library.ntc.edu.tw/toread/opac',1377 ISBN1378 )1379 driver.close()1380 worksheet.append_rows(gg.values.tolist())1381 return gg1382# ------------éå¾ç§æ大å¸-------------1383def HWU(ISBN):1384 sheet = ggSheet()1385 worksheet = sheet.get_worksheet(0)1386 driver = get_chrome()1387 gg = toread_crawler(1388 driver,1389 org='éå¾ç§æ大å¸',1390 org_url="http://120.102.129.237/toread/opac",1391 ISBN=ISBN1392 )1393 driver.close()1394 worksheet.append_rows(gg.values.tolist())1395 return gg1396# å½°å縣å
Œ
±åæ¸é¤¨ CHPL V1397def CHPL(ISBN):1398 sheet = ggSheet()1399 worksheet = sheet.get_worksheet(0)1400 driver = get_chrome()1401 gg = toread_crawler(1402 driver,1403 'å½°å縣å
Œ
±åæ¸é¤¨',1404 "https://library.toread.bocach.gov.tw/toread/opac",1405 ISBN1406 )1407 driver.close()1408 worksheet.append_rows(gg.values.tolist())1409 return gg1410# é«éé«å¸å¤§å¸ KMU V1411def KMU(ISBN):1412 sheet = ggSheet()1413 worksheet = sheet.get_worksheet(0)1414 driver = get_chrome()1415 gg = toread_crawler(1416 driver,1417 'é«éé«å¸å¤§å¸',1418 "https://toread.kmu.edu.tw/toread/opac",1419 ISBN1420 )1421 driver.close()1422 worksheet.append_rows(gg.values.tolist())1423 return gg1424# åç«èå°¾ç§æå¤§å¸ NFU V1425def NFU(ISBN):1426 sheet = ggSheet()1427 worksheet = sheet.get_worksheet(0)1428 driver = get_chrome()1429 gg = toread_crawler(1430 driver,1431 'åç«èå°¾ç§æ大å¸',1432 "https://toread.lib.nfu.edu.tw/toread/opac",1433 ISBN1434 )1435 driver.close()1436 worksheet.append_rows(gg.values.tolist())1437 return gg1438# èç´ç¿°ç§æå¤§å¸ SJU V1439def SJU(ISBN):1440 sheet = ggSheet()1441 worksheet = sheet.get_worksheet(0)1442 driver = get_chrome()1443 gg = toread_crawler(1444 driver,1445 'èç´ç¿°ç§æ大å¸',1446 "http://163.21.66.231:8080/toread/opac",1447 ISBN1448 )1449 driver.close()1450 worksheet.append_rows(gg.values.tolist())1451 return gg1452# æ±åç§æå¤§å¸ TNU V1453def TNU(ISBN):1454 sheet = ggSheet()1455 worksheet = sheet.get_worksheet(0)1456 driver = get_chrome()1457 gg = toread_crawler(1458 driver,1459 'æ±åç§æ大å¸',1460 "http://140.129.140.176/toread/opac",1461 ISBN1462 )1463 driver.close()1464 worksheet.append_rows(gg.values.tolist())1465 return gg1466# æ°çé«è·ç®¡çå°ç§å¸æ ¡ HSC V1467def HSC(ISBN):1468 sheet = ggSheet()1469 worksheet = sheet.get_worksheet(0)1470 driver = get_chrome()1471 gg = toread_crawler(1472 driver,1473 'æ°çé«è·ç®¡çå°ç§å¸æ ¡',1474 "http://163.25.34.60:8080/toread/opac",1475 ISBN1476 )1477 driver.close()1478 worksheet.append_rows(gg.values.tolist())1479 return gg1480# å´ä»é«è·ç®¡çå°ç§å¸æ ¡ CJC V1481def CJC(ISBN):1482 sheet = ggSheet()1483 worksheet = sheet.get_worksheet(0)1484 driver = get_chrome()1485 gg = toread_crawler(1486 driver,1487 'å´ä»é«è·ç®¡çå°ç§å¸æ ¡',1488 "http://toread.cjc.edu.tw/toread/opac",1489 ISBN1490 )1491 driver.close()1492 worksheet.append_rows(gg.values.tolist())1493 return gg1494# å
å¹é«äºç§æå¤§å¸ YPU V1495def YPU(ISBN):1496 sheet = ggSheet()1497 worksheet = sheet.get_worksheet(0)1498 driver = get_chrome()1499 gg = toread_crawler(1500 driver,1501 'å
å¹é«äºç§æ大å¸',1502 "http://120.106.195.31/toread/opac",1503 ISBN1504 )1505 driver.close()1506 worksheet.append_rows(gg.values.tolist())1507 return gg1508# 嶺æ±ç§æå¤§å¸ LTU V1509def LTU(ISBN):1510 sheet = ggSheet()1511 worksheet = sheet.get_worksheet(0)1512 driver = get_chrome()1513 gg = toread_crawler(1514 driver,1515 '嶺æ±ç§æ大å¸',1516 "http://192.192.100.39/toread/opac",1517 ISBN1518 )1519 driver.close()1520 worksheet.append_rows(gg.values.tolist())1521 return gg1522# æéå¤§å¸ MDU V1523def MDU(ISBN):1524 sheet = ggSheet()1525 worksheet = sheet.get_worksheet(0)1526 driver = get_chrome()1527 gg = toread_crawler(1528 driver,1529 'æé大å¸',1530 "http://210.60.94.144/toread/opac",1531 ISBN1532 )1533 driver.close()1534 worksheet.append_rows(gg.values.tolist())1535 return gg1536# 大èå¤§å¸ DYU V1537def DYU(ISBN):1538 sheet = ggSheet()1539 worksheet = sheet.get_worksheet(0)1540 driver = get_chrome()1541 gg = toread_crawler(1542 driver,1543 '大è大å¸',1544 "http://webpac.dyu.edu.tw/toread311_DYU/opac/Search.page",1545 ISBN1546 )1547 driver.close()1548 worksheet.append_rows(gg.values.tolist())1549 return gg1550# 建åç§æå¤§å¸ CTU V1551def CTU(ISBN):1552 sheet = ggSheet()1553 worksheet = sheet.get_worksheet(0)1554 driver = get_chrome()1555 gg = toread_crawler(1556 driver,1557 '建åç§æ大å¸',1558 "https://webpac.lib.ctu.edu.tw/toread/opac",1559 ISBN1560 )1561 driver.close()1562 worksheet.append_rows(gg.values.tolist())1563 return gg1564# åéç§æå¤§å¸ NKUT V1565def NKUT(ISBN):1566 sheet = ggSheet()1567 worksheet = sheet.get_worksheet(0)1568 driver = get_chrome()1569 gg = toread_crawler(1570 driver,1571 'åéç§æ大å¸',1572 "http://webpac.nkut.edu.tw/toread/opac",1573 ISBN1574 )1575 driver.close()1576 worksheet.append_rows(gg.values.tolist())1577 return gg1578# åç«é«éå¤§å¸ NUK V1579def NUK(ISBN):1580 sheet = ggSheet()1581 worksheet = sheet.get_worksheet(0)1582 driver = get_chrome()1583 gg = toread_crawler(1584 driver,1585 'åç«é«é大å¸',1586 "https://libopac.nuk.edu.tw/toread/opac",1587 ISBN1588 )1589 driver.close()1590 worksheet.append_rows(gg.values.tolist())1591 return gg1592# åç«æ±è¯å¤§å¸ NDHU V1593def NDHU(ISBN):1594 sheet = ggSheet()1595 worksheet = sheet.get_worksheet(0)1596 driver = get_chrome()1597 gg = toread_crawler(1598 driver,1599 'åç«æ±è¯å¤§å¸',1600 "https://books-lib.ndhu.edu.tw/toread/opac",1601 ISBN1602 )1603 driver.close()1604 worksheet.append_rows(gg.values.tolist())1605 return gg1606# ---------------------------------------Webpac2.0------------------------------------------------1607# webpac_two_cralwer()1608# åè大|å¤ç|義å®|ä¸å±±é«|åè¡é¢1609# åç«èºåèè¡å¤§å¸ TNUA V OK1610def TNUA(ISBN):1611 sheet = ggSheet()1612 worksheet = sheet.get_worksheet(0)1613 driver = get_chrome()1614 gg = webpac_two_cralwer(1615 driver,1616 'åç«èºåèè¡å¤§å¸',1617 "http://203.64.5.158/webpac/",1618 ISBN1619 )1620 driver.close()1621 worksheet.append_rows(gg.values.tolist())1622 return gg1623# åç«å¤çç§æå¤§å¸ NCUT V OK1624def NCUT(ISBN):1625 sheet = ggSheet()1626 worksheet = sheet.get_worksheet(0)1627 driver = get_chrome()1628 gg = webpac_two_cralwer(1629 driver,1630 'åç«å¤çç§æ大å¸',1631 "http://140.128.95.172/webpac/",1632 ISBN1633 )1634 driver.close()1635 worksheet.append_rows(gg.values.tolist())1636 return gg1637# 義å®å¤§å¸ ISU V1638def ISU(ISBN):1639 sheet = ggSheet()1640 worksheet = sheet.get_worksheet(0)1641 driver = get_chrome()1642 gg = webpac_two_cralwer(1643 driver,1644 '義å®å¤§å¸',1645 "http://webpac.isu.edu.tw/webpac/",1646 ISBN1647 )1648 driver.close()1649 worksheet.append_rows(gg.values.tolist())1650 return gg1651# ä¸å±±é«å¸å¤§å¸ CSMU V1652def CSMU(ISBN):1653 sheet = ggSheet()1654 worksheet = sheet.get_worksheet(0)1655 driver = get_chrome()1656 gg = webpac_two_cralwer(1657 driver,1658 'ä¸å±±é«å¸å¤§å¸',1659 "http://140.128.138.208/webpac/",1660 ISBN1661 )1662 driver.close()1663 worksheet.append_rows(gg.values.tolist())1664 return gg1665# å家è¡çç ç©¶é¢ NHRI V1666def NHRI(ISBN):1667 sheet = ggSheet()1668 worksheet = sheet.get_worksheet(0)1669 driver = get_chrome()1670 gg = webpac_two_cralwer(1671 driver,1672 'å家è¡çç 究é¢',1673 "http://webpac.nhri.edu.tw/webpac/",1674 ISBN1675 )1676 driver.close()1677 worksheet.append_rows(gg.values.tolist())1678 return gg1679# ------------------------------------cfm------------------------------------------1680# webpac_cfm_crawler()1681# å大|åå¸ç§å¤§|å¾·æ|é¾è¯|èºä¸å¸|ä¸åé«|äºæ´²|èºåå¸|æ
æ¿|æ¾ç§1682# åç«èºåå¤§å¸ NTPU X(å¡å¨é²tableåçé é¢)1683def NTPU(ISBN):1684 sheet = ggSheet()1685 worksheet = sheet.get_worksheet(0)1686 driver = get_chrome()1687 gg = webpac_cfm_crawler(1688 driver,1689 'åç«èºå大å¸',1690 "http://webpac.lib.ntpu.edu.tw/search.cfm",1691 ISBN1692 )1693 driver.close()1694 worksheet.append_rows(gg.values.tolist())1695 return gg1696# èºååå¸ç§æå¤§å¸ TPCU V1697def TPCU(ISBN):1698 sheet = ggSheet()1699 worksheet = sheet.get_worksheet(0)1700 driver = get_chrome()1701 gg = webpac_cfm_crawler(1702 driver,1703 'èºååå¸ç§æ大å¸',1704 "http://120.102.52.73/webpac/search.cfm",1705 ISBN1706 )1707 driver.close()1708 worksheet.append_rows(gg.values.tolist())1709 return gg1710# å¾·æ財ç¶ç§æå¤§å¸ TMUST V1711def TMUST(ISBN):1712 sheet = ggSheet()1713 worksheet = sheet.get_worksheet(0)1714 driver = get_chrome()1715 gg = webpac_cfm_crawler(1716 driver,1717 'å¾·æ財ç¶ç§æ大å¸',1718 "http://140.131.140.11/webpac/search.cfm",1719 ISBN1720 )1721 driver.close()1722 worksheet.append_rows(gg.values.tolist())1723 return gg1724# é¾è¯ç§æå¤§å¸ LHU V1725def LHU(ISBN):1726 sheet = ggSheet()1727 worksheet = sheet.get_worksheet(0)1728 driver = get_chrome()1729 gg = webpac_cfm_crawler(1730 driver,1731 'é¾è¯ç§æ大å¸',1732 "https://webpac.lhu.edu.tw/webpac/search.cfm",1733 ISBN1734 )1735 driver.close()1736 worksheet.append_rows(gg.values.tolist())1737 return gg1738# èºä¸å¸ç«åæ¸é¤¨ TCPL V1739def TCPL(ISBN):1740 sheet = ggSheet()1741 worksheet = sheet.get_worksheet(0)1742 driver = get_chrome()1743 gg = webpac_cfm_crawler(1744 driver,1745 'èºä¸å¸ç«åæ¸é¤¨',1746 "https://ipac.library.taichung.gov.tw/webpac/search.cfm",1747 ISBN1748 )1749 driver.close()1750 worksheet.append_rows(gg.values.tolist())1751 return gg1752# ä¸åé«è¥å¤§å¸ CMU V1753def CMU(ISBN):1754 sheet = ggSheet()1755 worksheet = sheet.get_worksheet(0)1756 driver = get_chrome()1757 gg = webpac_cfm_crawler(1758 driver,1759 'ä¸åé«è¥å¤§å¸',1760 "http://weblis.cmu.edu.tw/webpac/search.cfm",1761 ISBN1762 )1763 driver.close()1764 worksheet.append_rows(gg.values.tolist())1765 return gg1766# äºæ´²å¤§å¸ Asia V1767def Asia(ISBN):1768 sheet = ggSheet()1769 worksheet = sheet.get_worksheet(0)1770 driver = get_chrome()1771 gg = webpac_cfm_crawler(1772 driver,1773 'äºæ´²å¤§å¸',1774 "http://aulib.asia.edu.tw/webpac/search.cfm",1775 ISBN1776 )1777 driver.close()1778 worksheet.append_rows(gg.values.tolist())1779 return gg1780# èºåå¸ç«åæ¸é¤¨ TNPL V1781def TNPL(ISBN):1782 sheet = ggSheet()1783 worksheet = sheet.get_worksheet(0)1784 driver = get_chrome()1785 gg = webpac_cfm_crawler(1786 driver,1787 'èºåå¸ç«åæ¸é¤¨',1788 "https://lib.tnml.tn.edu.tw/webpac/search.cfm",1789 ISBN1790 )1791 driver.close()1792 worksheet.append_rows(gg.values.tolist())1793 return gg1794# æ
æ¿å¤§å¸ TCU V1795def TCU(ISBN):1796 sheet = ggSheet()1797 worksheet = sheet.get_worksheet(0)1798 driver = get_chrome()1799 gg = webpac_cfm_crawler(1800 driver,1801 'æ
æ¿å¤§å¸',1802 "http://www.webpac.tcu.edu.tw/webpac/search.cfm",1803 ISBN1804 )1805 driver.close()1806 worksheet.append_rows(gg.values.tolist())1807 return gg1808# åç«æ¾æ¹ç§æå¤§å¸ NPU V OK1809def NPU(ISBN):1810 sheet = ggSheet()1811 worksheet = sheet.get_worksheet(0)1812 driver = get_chrome()1813 gg = webpac_cfm_crawler(1814 driver,1815 'åç«æ¾æ¹ç§æ大å¸',1816 "https://inspire.npu.edu.tw/webpac/search.cfm",1817 ISBN1818 )1819 driver.close()1820 worksheet.append_rows(gg.values.tolist())1821 return gg1822# ------------------------------被ç¨ç«åºä¾çåºé---------------------------------------1823def åºéå¸å
Œ
±åæ¸é¤¨(driver, org, org_url, ISBN):1824 try:1825 # é²å
¥ï¼æå°ä¸»é ï¼1826 driver.get(org_url)1827 # çå¾
é»æï¼é²éæ¥è©¢ï¼æéï¼æ¥èé»æ1828 WebDriverWait(driver, 30).until(1829 EC.element_to_be_clickable((By.LINK_TEXT, 'é²é檢索'))).click()1830 time.sleep(2) # JavaScript åç«ï¼å¼·å¶çå¾
1831 # çå¾
å®ä½ï¼ä¸æå¼é¸å®ï¼ï¼é¸æ以 ISBN æ¹å¼æå°1832 search_field = WebDriverWait(driver, 10).until(1833 EC.presence_of_element_located((By.ID, 'as_type_1')))1834 select = Select(search_field)1835 select.select_by_value('i')1836 # å®ä½ï¼æå°æ¬ï¼ï¼è¼¸å
¥ ISBN1837 search_input = driver.find_element_by_id('as_keyword_1')1838 search_input.send_keys(ISBN)1839 search_input.send_keys(Keys.ENTER)1840 time.sleep(8) # åºéç系統太è©ç°äºï¼å¼·å¶çå¾
1841 soup = BeautifulSoup(driver.page_source, "html.parser")1842 results = len(soup.find_all("div", "list_box"))1843 if results < 2:1844 WebDriverWait(driver, 10).until(1845 EC.presence_of_element_located(1846 (By.CSS_SELECTOR, "table.list.list_border")))1847 time.sleep(2)1848 table = pd.read_html(driver.page_source)[0]1849 else:1850 table = []1851 for li in soup.find_all("div", "list_box"):1852 url_temp = "https://webpac.klccab.gov.tw/webpac/" + li.find(1853 "a", "btn")["href"]1854 driver.get(url_temp)1855 wait.until(1856 EC.presence_of_element_located(1857 (By.CSS_SELECTOR, "table.list.list_border")))1858 time.sleep(2)1859 table.append(1860 pd.read_html(driver.page_source, encoding="utf-8")[0])1861 table = pd.concat(table, axis=0, ignore_index=True)1862 table['åæ¸é¤¨'], table['é£çµ'] = org, driver.current_url1863 table = organize_columns(table)1864 table = statuss(table)1865 return table1866 except:1867 print(f'ã{ISBN}ãå¨ã{org_url}ãç¡æ³ç¬å')1868# åºéå¸å
Œ
±åæ¸é¤¨ KLCCAB X(ç¡é¤¨èè³æææææ)1869def KLCCAB(ISBN):1870 sheet = ggSheet()1871 worksheet = sheet.get_worksheet(0)1872 driver = get_chrome()1873 gg = åºéå¸å
Œ
±åæ¸é¤¨(1874 driver,1875 'åºéå¸å
Œ
±åæ¸é¤¨',1876 "https://webpac.klccab.gov.tw/webpac/search.cfm",1877 ISBN1878 )1879 driver.close()1880 worksheet.append_rows(gg.values.tolist())1881 return gg1882# ------------------------------------é£å½¢å®¹çç¹æ®------------------------------------------1883# sirsidynix_crawler()1884# ä¸ç§å¤§|åæ縣|åè大1885# åç«èºä¸ç§æå¤§å¸ NUTC1886def NUTC(ISBN):1887 sheet = ggSheet()1888 worksheet = sheet.get_worksheet(0)1889 driver = get_chrome()1890 gg = sirsidynix_crawler(1891 driver,1892 'åç«èºä¸ç§æ大å¸',1893 "https://ntit.ent.sirsidynix.net/client/zh_TW/NUTC",1894 ISBN1895 )1896 driver.close()1897 worksheet.append_rows(gg.values.tolist())1898 return gg1899# åæ縣åæ¸é¤¨ NTCPL1900def NTCPL(ISBN):1901 sheet = ggSheet()1902 worksheet = sheet.get_worksheet(0)1903 driver = get_chrome()1904 gg = sirsidynix_crawler(1905 driver,1906 'åæ縣åæ¸é¤¨',1907 'https://nccc.ent.sirsi.net/client/zh_TW/main',1908 ISBN1909 )1910 driver.close()1911 worksheet.append_rows(gg.values.tolist())1912 return gg1913# åç«èºåèè¡å¤§å¸ TNNUA OK1914def TNNUA(ISBN):1915 sheet = ggSheet()1916 worksheet = sheet.get_worksheet(0)1917 driver = get_chrome()1918 gg = sirsidynix_crawler(1919 driver,1920 'åç«èºåèè¡å¤§å¸',1921 'https://tnnua.ent.sirsi.net/client/zh_TW/tnnua/?',1922 ISBN1923 )1924 driver.close()1925 worksheet.append_rows(gg.values.tolist())1926 return gg1927# ------------------------------------æåå±æä¸------------------------------------------1928# moc_thm_crawler()1929# èºå²é¤¨|èºæ館|å²å館|1930# åç«èºç£å²åæååç©é¤¨ NMP1931def NMP(ISBN):1932 sheet = ggSheet()1933 worksheet = sheet.get_worksheet(0)1934 driver = get_chrome()1935 gg = moc_thm_crawler(1936 driver,1937 'åç«èºç£å²åæååç©é¤¨',1938 "https://lib.moc.gov.tw/F?func=find-d-0&local_base=THM04",1939 ISBN1940 )1941 driver.close()1942 worksheet.append_rows(gg.values.tolist())1943 return gg1944# ---------------------------------被ç¨ç«åºä¾çåå----------------------------------------1945def å家åæ¸é¤¨(driver, org, org_url, ISBN):1946 try:1947 driver.get(org_url)1948 select_ISBN_strategy(driver, 'find_code', 'ISBN')1949 search_ISBN(driver, ISBN, 'request')1950 # é»æï¼æ¸å¨åªè£¡(è«é»é¸)ï¼ï¼é²å
¥ï¼æ¸ç®è³æï¼1951 wait_for_element_clickable(driver, 'æ¸å¨åªè£¡(è«é»é¸)').click()1952 table = accurately_find_table_and_read_it(driver, 'table', -2)1953 if 0 in table.columns:1954 print(f'å¨ã{org}ãæ¾ä¸å°ã{ISBN}ã')1955 return1956 table['åæ¸é¤¨'], table['é£çµ'] = org, driver.current_url1957 table = organize_columns(table)1958 except Exception as e:1959 # æ²æç©ä»¶å¯ä»¥ clickï¼è¡¨ç¤ºï¼é¶çï¼æå°çµæ1960 print(f'å¨ã{org}ãæå°ã{ISBN}ãæï¼ç¼çé¯èª¤ï¼é¯èª¤è¨æ¯çºï¼ã{e}ãï¼')1961 return1962 return table1963# å家åæ¸é¤¨ NCL V1964def NCL(ISBN):1965 sheet = ggSheet()1966 worksheet = sheet.get_worksheet(0)1967 driver = get_chrome()1968 gg = å家åæ¸é¤¨(1969 driver,1970 'å家åæ¸é¤¨',1971 "https://aleweb.ncl.edu.tw/F",1972 ISBN1973 )1974 driver.close()1975 worksheet.append_rows(gg.values.tolist())1976 return gg1977# ---------------------------------被ç¨ç«åºä¾çä¸æ°----------------------------------------1978def ä¸æ°å¤§å¸(driver, org, org_url, ISBN):1979 try:1980 driver.get(org_url)1981 search_ISBN(driver, ISBN, 'q')1982 table = accurately_find_table_and_read_it(driver, '#holdingst')1983 table['åæ¸é¤¨'], table['é£çµ'] = org, driver.current_url1984 table = organize_columns(table)1985 except Exception as e:1986 print(f'å¨ã{org}ãæ¾ä¸å°ã{ISBN}ã')1987 return1988 else:1989 table = statuss(table)1990 return table1991# ä¸æ°å¤§å¸ SHU V OK1992def SHU(ISBN):1993 sheet = ggSheet()1994 worksheet = sheet.get_worksheet(0)1995 driver = get_chrome()1996 gg = ä¸æ°å¤§å¸(1997 driver,1998 'ä¸æ°å¤§å¸',1999 "https://koha.shu.edu.tw/",2000 ISBN2001 )2002 driver.close()2003 worksheet.append_rows(gg.values.tolist())2004 return gg2005# å°åæµ·æ´ç§æå¤§å¸ TUMT V2006def TUMT(ISBN):2007 sheet = ggSheet()2008 worksheet = sheet.get_worksheet(0)2009 driver = get_chrome()2010 gg = å°åæµ·æ´ç§æ大å¸(2011 driver,2012 'å°åæµ·æ´ç§æ大å¸',2013 'http://140.129.253.4/webopac7/sim_data2.php?pagerows=15&orderby=BRN&pageno=1&bn=',2014 ISBN2015 )2016 driver.close()2017 worksheet.append_rows(gg.values.tolist())2018 return gg2019# ---------------------------------被ç¨ç«åºä¾çæ實ç§å¤§----------------------------------------2020def æ實ç§æ大å¸(driver, org, org_url, ISBN):2021 try:2022 table = []2023 driver.get(org_url)2024 search_ISBN(driver, ISBN, 'DB.IN1')2025 if wait_for_element_present(driver, 'span.sm9'):2026 search_result_message = BeautifulSoup(2027 driver.page_source, 'html.parser').find_all('span', 'sm9')[-2].text2028 search_result_regex = re.compile(r'\d')2029 mo = search_result_regex.search(search_result_message)2030 if int(mo.group()) == 0:2031 print(f'å¨ã{org}ãæ¾ä¸å°ã{ISBN}ã')2032 return2033 driver.find_elements_by_tag_name('a')[1].click()2034 tgt = accurately_find_table_and_read_it(driver, 'table', -1)2035 tgt['åæ¸é¤¨'], tgt['é£çµ'] = org, driver.current_url2036 table.append(tgt)2037 except Exception as e:2038 print(f'å¨ã{org}ãæå°ã{ISBN}ãæï¼ç¼çé¯èª¤ï¼é¯èª¤è¨æ¯çºï¼ã{e}ãï¼')2039 return2040 else:2041 table = organize_columns(table)2042 table = statuss(table)2043 return table2044# æ實ç§æå¤§å¸ MITUST2045def MITUST(ISBN):2046 sheet = ggSheet()2047 worksheet = sheet.get_worksheet(0)2048 driver = get_chrome()2049 gg = æ實ç§æ大å¸(2050 driver,2051 'æ實ç§æ大å¸',2052 'http://120.105.200.52/xsearch-b.html',2053 ISBN2054 )2055 driver.close()2056 worksheet.append_rows(gg.values.tolist())2057 return gg2058# ------------------------------------------Primo-----------------------------------------2059# primo_crawler()2060# èºå¤§|æ¿å¤§|æ·¡æ±|éå³|æ±å³2061def primo_crawler(driver, org, url_front, ISBN, url_behind, tcn):2062 url = url_front + ISBN + url_behind2063 primo_lst = []2064 try:2065 # é²å
¥ã館è系統ãé é¢2066 driver.get(url)2067 try: # éå§ç¬è²2068 editions = wait_for_elements_present(2069 driver, 'item-title', 20, By.CLASS_NAME)2070 print("é²å
¥æå°")2071 """2072 try: #æ¾ææ²æå¤åçæ¬çç®é 2073 if org != "åç«èºç£å¤§å¸": #æé¤å°å¤§ï¼ä¸ç¶å°å¤§æ²è¾¦æ³è·2074 edition_check = wait_for_element_clickable(2075 driver, "neutralized-button.arrow-link-button.md-button.md-primoExplore-theme.md-ink-ripple", 20, By.CLASS_NAME).click()2076 except:2077 edition_check = None2078 2079 if edition_check != None: #å¦ææç®é ï¼ä»£è¡¨æå¤åçæ¬ï¼åç¬ä¸æ¬¡çæ¬ï¼2080 print("æå¤åçæ¬QQ")2081 time.sleep(5)2082 editions = wait_for_elements_present(2083 driver, 'item-title', 20, By.CLASS_NAME)2084 else:2085 editions[0].click()2086 print(edition_check)2087 """2088 2089 if len(editions) > 1: # å¦ææå¤é¢æå
©åçæ¬(é»èªé»é²å»ä¸æååçæ¬äºå¦)(ex.æ¿å¤§ 9789861371955)ï¼ç´æ¥äº¤çµ¦ä¸é¢èç2090 pass2091 else: # å¦ææå¤é¢åªæä¸åçæ¬ï¼é£æå¯è½é»é²å»éæååï¼å
clické²å»ï¼ååä¸åçæ¬è·å¤åçæ¬ççæ³2092 time.sleep(5)2093 editions[0].click()2094 if org == "åç«æ¿æ²»å¤§å¸" or org == "åç«æ¸
è¯å¤§å¸" or org == "åç«é½æ交é大å¸":2095 try:2096 editions = driver.find_elements_by_class_name(2097 'item-title', 10) # éæåæ¯ç¬¬äºå±¤çåçæ¬äºï¼(ex.æ¿å¤§ 9789869109321)2098 print("æ該æ¯ææ¾å°è£¡é¢ççæ¬äºå¦")2099 except:2100 pass2101 2102 try: # å
æ¾åå確å®æ¯ä¸æ¯å¨æ裡層äº2103 back_check = wait_for_element_present(2104 driver, "md-icon-button.close-button.full-view-navigation.md-button.md-primoExplore-theme.md-ink-ripple")2105 print("æ¾ååæåï¼æºåæ¾è¡¨æ ¼")2106 except:2107 back_check = None2108 print("æ²æååï¼é²çæ¬è¿´å")2109 2110 if back_check == None: # å¤åçæ¬æè¦åè·è¿´å(æ¾ä¸å°åå代表ä¸å¨æ裡é¢ï¼å¯ç¥ä¸æ¯ä¸åçæ¬)2111 print("é²å¤åçæ¬")2112 for i in range(0, len(editions)): # æå¹¾åçæ¬å°±è·å¹¾æ¬¡ï¼ä¸ç®¡åªä¸å±¤çæ¬é½é©ç¨2113 time.sleep(5)2114 into = editions[i].click()2115 print("çæ¬" + str(i))2116 if org == "åç«å±æ±ç§æ大å¸" or org == "åç«é«éé¤æ
大å¸":2117 primo_lst += primo_two_finding(driver, org)2118 else:2119 primo_lst += primo_finding(driver, org, tcn)2120 try:2121 back2 = wait_for_element_clickable(2122 driver, "md-icon-button.close-button.full-view-navigation.md-button.md-primoExplore-theme.md-ink-ripple").click()2123 except:2124 back2 = None2125 else: # å¦æåªæä¸åçæ¬(æååçææ)ï¼é£åé¢å·²ç¶clickéäºä¸è½åå2126 if org == "åç«å±æ±ç§æ大å¸" or org == "åç«é«éé¤æ
大å¸":2127 primo_lst += primo_two_finding(driver, org)2128 print(primo_lst)2129 else:2130 print("é²ä¸åçæ¬çprimo_finding")2131 primo_lst += primo_finding(driver, org, tcn)2132 print(primo_lst)2133 except:2134 print("ç¬è²å¤±æ")2135 except:2136 print("æ²é²ç¶²å")2137 table = pd.DataFrame(primo_lst)2138 table.rename(columns={0: 'åæ¸é¤¨', 1: '館èå°', 2: 'ç´¢æ¸è',2139 3: '館èçæ
', 4: 'é£çµ'}, inplace=True)2140 table = statuss(table)2141 return table2142# åç«èºç£å¤§å¸ NTU V2143def NTU(ISBN):2144 sheet = ggSheet()2145 worksheet = sheet.get_worksheet(0)2146 driver = get_chrome()2147 gg = primo_crawler(2148 driver,2149 'åç«èºç£å¤§å¸',2150 "https://ntu.primo.exlibrisgroup.com/discovery/search?query=any,contains,",2151 ISBN,2152 "&tab=Everything&search_scope=MyInst_and_CI&vid=886NTU_INST:886NTU_INST&offset=0",2153 "layout-align-space-between-center.layout-row.flex-100"2154 )2155 driver.close()2156 worksheet.append_rows(gg.values.tolist())2157 return gg2158# åç«æ¿æ²»å¤§å¸ NCCU V2159def NCCU(ISBN):2160 sheet = ggSheet()2161 worksheet = sheet.get_worksheet(0)2162 driver = get_chrome()2163 gg = primo_crawler(2164 driver,2165 'åç«æ¿æ²»å¤§å¸',2166 "https://nccu.primo.exlibrisgroup.com/discovery/search?query=any,contains,",2167 ISBN,2168 "&tab=Everything&search_scope=MyInst_and_CI&vid=886NCCU_INST:886NCCU_INST",2169 "layout-align-space-between-center.layout-row.flex-100"2170 )2171 driver.close()2172 worksheet.append_rows(gg.values.tolist())2173 return gg2174# æ·¡æ±å¤§å¸ TKU V OK2175def TKU(ISBN):2176 sheet = ggSheet()2177 worksheet = sheet.get_worksheet(0)2178 driver = get_chrome()2179 gg = primo_crawler(2180 driver,2181 'æ·¡æ±å¤§å¸',2182 "https://uco-network.primo.exlibrisgroup.com/discovery/search?query=any,contains,",2183 ISBN,2184 "&tab=Everything&search_scope=MyInst_and_CI&vid=886UCO_TKU:886TKU_INST&lang=zh-tw&offset=0",2185 "neutralized-button.layout-full-width.layout-display-flex.md-button.md-ink-ripple.layout-row"2186 )2187 driver.close()2188 worksheet.append_rows(gg.values.tolist())2189 return gg2190# éå³å¤§å¸ MCU V(ç´¢æ¸èæ¯ç©ºç) OK2191def MCU(ISBN):2192 sheet = ggSheet()2193 worksheet = sheet.get_worksheet(0)2194 driver = get_chrome()2195 gg = primo_crawler(2196 driver,2197 'éå³å¤§å¸',2198 "https://uco-mcu.primo.exlibrisgroup.com/discovery/search?query=any,contains,",2199 ISBN,2200 "&tab=Everything&search_scope=MyInst_and_CI&vid=886UCO_MCU:886MCU_INST&lang=zh-tw&offset=0",2201 "md-2-line.md-no-proxy._md"2202 )2203 driver.close()2204 worksheet.append_rows(gg.values.tolist())2205 return gg2206# æ±å³å¤§å¸ SCU V OK2207def SCU(ISBN):2208 sheet = ggSheet()2209 worksheet = sheet.get_worksheet(0)2210 driver = get_chrome()2211 gg = primo_crawler(2212 driver,2213 'æ±å³å¤§å¸',2214 "https://uco-scu.primo.exlibrisgroup.com/discovery/search?query=any,contains,",2215 ISBN,2216 "&tab=Everything&search_scope=MyInst_and_CI&vid=886UCO_SCU:886SCU_INST&lang=zh-tw&offset=0",2217 "md-2-line.md-no-proxy._md"2218 )2219 driver.close()2220 worksheet.append_rows(gg.values.tolist())2221 return gg2222# åç«é«éç§æå¤§å¸ NKUST V OK2223def NKUST(ISBN):2224 sheet = ggSheet()2225 worksheet = sheet.get_worksheet(0)2226 driver = get_chrome()2227 gg = primo_crawler(2228 driver,2229 'åç«é«éç§æ大å¸',2230 "https://nkust.primo.exlibrisgroup.com/discovery/search?query=any,contains,",2231 ISBN,2232 "&tab=Everything&search_scope=MyInst_and_CI&vid=886NKUST_INST:86NKUST&lang=zh-tw&offset=0,",2233 "layout-align-space-between-center.layout-row.flex-100"2234 )2235 driver.close()2236 worksheet.append_rows(gg.values.tolist())2237 return gg2238# åç«æ¸
è¯å¤§å¸ NTHU2239def NTHU(ISBN):2240 sheet = ggSheet()2241 worksheet = sheet.get_worksheet(0)2242 driver = get_chrome()2243 gg = primo_crawler(2244 driver,2245 'åç«æ¸
è¯å¤§å¸',2246 "https://nthu.primo.exlibrisgroup.com/discovery/search?query=any,contains,",2247 ISBN,2248 "&tab=LibraryCatalog&search_scope=MyInstitution&vid=886UST_NTHU:886UST_NTHU&lang=zh-tw&offset=0",2249 "layout-align-space-between-center.layout-row.flex-100"2250 )2251 driver.close()2252 worksheet.append_rows(gg.values.tolist())2253 return gg2254# åç«é½æ交éå¤§å¸ NYCU2255def NYCU(ISBN):2256 sheet = ggSheet()2257 worksheet = sheet.get_worksheet(0)2258 driver = get_chrome()2259 gg = primo_crawler(2260 driver,2261 'åç«é½æ交é大å¸',2262 "https://nycu.primo.exlibrisgroup.com/discovery/search?query=any,contains,",2263 ISBN,2264 "&tab=Everything&search_scope=MyInst_and_CI&vid=886UST_NYCU:886UST_NYCU&lang=zh-tw&offset=0",2265 "layout-align-space-between-center.layout-row.flex-100"2266 )2267 driver.close()2268 worksheet.append_rows(gg.values.tolist())2269 return gg2270# ------------------------------------------Primo v2-----------------------------------------2271# primo_two_crawler()2272# å±ç§å¤§|é«é¤|é«ç§å¤§2273def primo_two_crawler(driver, org, url_front, ISBN, url_behind):2274 url = url_front + ISBN + url_behind2275 primo_two_lst = []2276 def primo_two_finding(org): # ç¬è³è¨çdef2277 sub_df_lst = []2278 time.sleep(2)2279 try:2280 back = driver.find_element_by_css_selector(2281 ".tab-header .back-button.button-with-icon.zero-margin.md-button.md-primoExplore-theme.md-ink-ripple")2282 except:2283 back = None2284 if back != None:2285 back.click()2286 similar_xpath = "/html/body/primo-explore/div[3]/div/md-dialog/md-dialog-content/sticky-scroll/prm-full-view/div/div/div[2]/div/div[1]/div[4]/div/prm-full-view-service-container/div[2]/div/prm-opac/md-tabs/md-tabs-content-wrapper/md-tab-content[2]/div/md-content/prm-location-items/div[2]/div[1]/p/span["2287 status = driver.find_element_by_xpath(similar_xpath + "1]")2288 place = driver.find_element_by_xpath(similar_xpath + "3]")2289 num = driver.find_element_by_xpath(similar_xpath + "5]")2290 now_url = driver.current_url2291 number = num.text.replace("(", "").replace(")", "")2292 new_row = [org, place.text, number, status.text, now_url]2293 sub_df_lst.append(new_row)2294 return sub_df_lst2295 try:2296 # é²å
¥ã館è系統ãé é¢2297 driver.get(url)2298 # çå¾
ï¼é²éæ¥è©¢çæéï¼ç´å°åºç¾ï¼click2299 time.sleep(15)2300 try: # éå§ç¬è²2301 editions = driver.find_elements_by_class_name('item-title', 20)2302 if len(editions) > 1: # å¦ææå¤é¢æå
©x`åçæ¬(é»èªé»é²å»ä¸æååçæ¬äºå¦)(ex.æ¿å¤§ 9789861371955)ï¼ç´æ¥äº¤çµ¦ä¸é¢èç2303 pass2304 else: # å¦ææå¤é¢åªæä¸åçæ¬ï¼é£æå¯è½é»é²å»éæååï¼å
clické²å»ï¼ååä¸åçæ¬è·å¤åçæ¬ççæ³2305 time.sleep(2)2306 editions[0].click()2307 time.sleep(5)2308 editions = driver.find_elements_by_class_name(2309 'item-title', 20) # éæåæ¯ç¬¬äºå±¤çåçæ¬äºï¼(ex.æ¿å¤§ 9789869109321)2310 try: # å
æ¾åå確å®æ¯ä¸æ¯å¨æ裡層äº2311 back_check = driver.find_element_by_class_name(2312 "md-icon-button.close-button.full-view-navigation.md-button.md-primoExplore-theme.md-ink-ripple")2313 except:2314 back_check = None2315 if back_check == None: # å¤åçæ¬æè¦åè·è¿´å(æ¾ä¸å°åå代表ä¸å¨æ裡é¢ï¼å¯ç¥ä¸æ¯ä¸åçæ¬)2316 for i in range(0, len(editions)): # æå¹¾åçæ¬å°±è·å¹¾æ¬¡ï¼ä¸ç®¡åªä¸å±¤çæ¬é½é©ç¨2317 into = editions[i].click()2318 time.sleep(3)2319 primo_two_lst += primo_two_finding(org)2320 try:2321 back2 = driver.find_element_by_class_name(2322 "md-icon-button.close-button.full-view-navigation.md-button.md-primoExplore-theme.md-ink-ripple").click()2323 except:2324 back2 = None2325 else: # å¦æåªæä¸åçæ¬(æååçææ)ï¼é£åé¢å·²ç¶clickéäºä¸è½åå2326 time.sleep(3)2327 primo_two_lst += primo_two_finding(org)2328 except:2329 pass2330 except:2331 pass2332 table = pd.DataFrame(primo_two_lst)2333 table.rename(columns={0: 'åæ¸é¤¨', 1: '館èå°', 2: 'ç´¢æ¸è',2334 3: '館èçæ
', 4: 'é£çµ'}, inplace=True)2335 table = statuss(table)2336 return table2337# åç«å±æ±ç§æå¤§å¸ NPUST V2338def NPUST(ISBN):2339 sheet = ggSheet()2340 worksheet = sheet.get_worksheet(0)2341 driver = get_chrome()2342 gg = primo_crawler(2343 driver,2344 'åç«å±æ±ç§æ大å¸',2345 "http://primo.lib.npust.edu.tw/primo-explore/search?institution=NPUST&vid=NPUST&tab=default_tab&search_scope=SearchAll&mode=basic&query=any,contains,",2346 ISBN,2347 "&displayMode=full&bulkSize=10&highlight=true&dum=true&lang=zh_TW&displayField=all&pcAvailabiltyMode=true",2348 ""2349 )2350 driver.close()2351 worksheet.append_rows(gg.values.tolist())2352 return gg2353# åç«é«éé¤æ
å¤§å¸ NKUHT V2354def NKUHT(ISBN):2355 sheet = ggSheet()2356 worksheet = sheet.get_worksheet(0)2357 driver = get_chrome()2358 gg = primo_crawler(2359 driver,2360 'åç«é«éé¤æ
大å¸',2361 "https://find.nkuht.edu.tw/primo-explore/search?query=any,contains,",2362 ISBN,2363 "&tab=default_tab&search_scope=%E6%9F%A5%E9%A4%A8%E8%97%8F&vid=NKUHT_N&offset=0",2364 ""2365 )2366 driver.close()2367 worksheet.append_rows(gg.values.tolist())2368 return gg2369# ------------------------------------------ç¶ é»é»----------------------------------------------2370# primo_greendot_crawler()2371# é·åº|ä¸æ£|é·æ¦®2372def primo_greendot_crawler(driver, org, url_front, ISBN, url_behind):2373 url = url_front + ISBN + url_behind2374 primo_greendot_lst = []2375 try:2376 driver.get(url)2377 try: # åªæä¸åçæ¬2378 place_click = wait_for_element_clickable(2379 driver, 'exlidResult0-LocationsTab', 10, By.ID).click()2380 primo_greendot_lst += primo_greendot_finding(driver, org)2381 except: # æå¤åçæ¬ï¼æ以è¦é»é²å»åå2382 manyeditions = wait_for_element_clickable(2383 driver, 'titleLink', 10, By.ID).click()2384 for i in range(1, 10): # åè¨æååçæ¬å§2385 try:2386 id = 'exlidResult' + str(i) + '-LocationsTab'2387 place2_click = wait_for_element_clickable(2388 driver, id, 15, By.ID).click()2389 primo_greendot_lst += primo_greendot_finding(driver, org)2390 except:2391 continue2392 except:2393 pass2394 table = pd.DataFrame(primo_greendot_lst)2395 table.rename(columns={0: 'åæ¸é¤¨', 1: '館èå°', 2: 'ç´¢æ¸è',2396 3: '館èçæ
', 4: 'é£çµ'}, inplace=True)2397 table = statuss(table)2398 return table2399# é·åºå¤§å¸ CGU V OK2400def CGU(ISBN):2401 sheet = ggSheet()2402 worksheet = sheet.get_worksheet(0)2403 driver = get_chrome()2404 gg = primo_greendot_crawler(2405 driver,2406 'é·åºå¤§å¸',2407 "https://primo.lib.cgu.edu.tw/primo_library/libweb/action/search.do?fn=search&ct=search&initialSearch=true&mode=Advanced&tab=default_tab&indx=1&dum=true&srt=rank&vid=CGU&frbg=&tb=t&vl%2812508471UI0%29=isbn&vl%2812508471UI0%29=title&vl%2812508471UI0%29=isbn&vl%281UIStartWith0%29=contains&vl%28freeText0%29=",2408 ISBN,2409 "&vl%28boolOperator0%29=AND&vl%2812508474UI1%29=creator&vl%2812508474UI1%29=title&vl%2812508474UI1%29=creator&vl%281UIStartWith1%29=contains&vl%28freeText1%29=&vl%28boolOperator1%29=AND&vl%2812508470UI2%29=any&vl%2812508470UI2%29=title&vl%2812508470UI2%29=any&vl%281UIStartWith2%29=contains&vl%28freeText2%29=&vl%28boolOperator2%29=AND&vl%2812626940UI3%29=any&vl%2812626940UI3%29=title&vl%2812626940UI3%29=any&vl%281UIStartWith3%29=contains&vl%28freeText3%29=&vl%28boolOperator3%29=AND&vl%28D2240502UI4%29=all_items&vl%2853081356UI5%29=all_items&vl%28D2240500UI6%29=all_items&Submit=%E6%AA%A2%E7%B4%A2"2410 )2411 driver.close()2412 worksheet.append_rows(gg.values.tolist())2413 return gg2414# åç«ä¸æ£å¤§å¸ CCU V OK2415def CCU(ISBN):2416 sheet = ggSheet()2417 worksheet = sheet.get_worksheet(0)2418 driver = get_chrome()2419 gg = primo_greendot_crawler(2420 driver,2421 'åç«ä¸æ£å¤§å¸',2422 "http://primo.lib.ccu.edu.tw/primo_library/libweb/action/search.do?fn=search&ct=search&initialSearch=true&mode=Advanced&tab=default_tab&indx=1&dum=true&srt=rank&vid=CCU&frbg=&tb=t&vl%28256032279UI0%29=isbn&vl%28256032279UI0%29=title&vl%28256032279UI0%29=any&vl%281UIStartWith0%29=contains&vl%28freeText0%29=",2423 ISBN,2424 "&vl%282853831UI0%29=AND&vl%28256032278UI1%29=any&vl%28256032278UI1%29=title&vl%28256032278UI1%29=any&vl%281UIStartWith1%29=contains&vl%28freeText1%29=&vl%282853829UI1%29=AND&vl%28256032320UI2%29=any&vl%28256032320UI2%29=title&vl%28256032320UI2%29=any&vl%281UIStartWith2%29=contains&vl%28freeText2%29=&vl%282853831UI2%29=AND&vl%28D2853835UI3%29=all_items&vl%28256032346UI4%29=all_items&vl%28D2853833UI5%29=all_items&Submit=%E6%AA%A2%E7%B4%A2"2425 )2426 driver.close()2427 worksheet.append_rows(gg.values.tolist())2428 return gg2429# é·æ¦®å¤§å¸ CJCU V OK2430def CJCU(ISBN):2431 sheet = ggSheet()2432 worksheet = sheet.get_worksheet(0)2433 driver = get_chrome()2434 gg = primo_greendot_crawler(2435 driver,2436 'é·æ¦®å¤§å¸',2437 "http://discovery.lib.cjcu.edu.tw:1701/primo_library/libweb/action/search.do?fn=search&ct=search&initialSearch=true&mode=Advanced&tab=ils_pc&indx=1&dum=true&srt=rank&vid=CJCU&frbg=&tb=t&vl%28D2348462UI0%29=any&vl%28D2348462UI0%29=title&vl%28D2348462UI0%29=any&vl%281UIStartWith0%29=contains&vl%28freeText0%29=,",2438 ISBN,2439 "&vl%28boolOperator0%29=AND&vl%2812508474UI1%29=creator&vl%2812508474UI1%29=title&vl%2812508474UI1%29=creator&vl%281UIStartWith1%29=contains&vl%28freeText1%29=&vl%28boolOperator1%29=AND&vl%2812508470UI2%29=any&vl%2812508470UI2%29=title&vl%2812508470UI2%29=any&vl%281UIStartWith2%29=contains&vl%28freeText2%29=&vl%28boolOperator2%29=AND&vl%2812626940UI3%29=any&vl%2812626940UI3%29=title&vl%2812626940UI3%29=any&vl%281UIStartWith3%29=contains&vl%28freeText3%29=&vl%28boolOperator3%29=AND&vl%28D2240502UI4%29=all_items&vl%2853081356UI5%29=all_items&vl%28D2240500UI6%29=all_items&Submit=%E6%AA%A2%E7%B4%A2"2440 )2441 driver.close()2442 worksheet.append_rows(gg.values.tolist())2443 return gg2444# ----------------------------------------è¦ä¸ç´é»é²å»------------------------------------------2445# clickclick_crawler()2446# 馬åé«|å·¥ç é¢|æå¿|é·åºç§å¤§|æ¸
è¯|æ¨å|èºå大|å
©å»³é¢|å°ç¥2447def clickclick_crawler(driver, org, org_url, ISBN, xpath_num, gogo_xpath, xpath_detail, table_xpath, index_lst):2448 clickclick_lst = []2449 into_1_lst = ["馬åé«å¸é¢", "å·¥æ¥æè¡ç 究é¢", "åç«æ¸
è¯å¤§å¸", "åç«èºç£ç¾è¡é¤¨", "åç«èºç£å²åæååç©é¤¨"]2450 try:2451 # åä¸é¡çé²å
¥æ¹å¼2452 driver.get(org_url)2453 if org in into_1_lst: # é£ç¨®é¡åçæ²è¾¦æ¹ç¶²åé²é²éæå°QQ2454 pro_search = wait_for_element_clickable(2455 driver, "é²éæ¥è©¢", 10, By.LINK_TEXT).click()2456 print("é²å
¥é²éæ¥è©¢")2457 # ææISBNæå°ï¼xpath_num2458 ISBN_xpath = "/html/body/form/table[1]/tbody/tr[2]/td[1]/select/option[" + xpath_num + "]"2459 use_ISBN = wait_for_element_clickable(2460 driver, ISBN_xpath, 10, By.XPATH).click()2461 print("ä¸æé¸å®æ¹ISBN")2462 search_input = wait_for_element_clickable(2463 driver, "request", 5, By.NAME)2464 search_input.send_keys(ISBN)2465 print("輸å
¥ISBN")2466 gogo = wait_for_element_clickable(2467 driver, gogo_xpath, 5, By.XPATH).click() # æä¸ç¢ºå®ï¼gogo_xpath2468 print("é»ææå°")2469 click_result = wait_for_element_clickable(2470 driver, "/html/body/form/table[1]/tbody/tr[2]/td[4]/a", 10, By.XPATH).click()2471 print("é»ææå°çµæçæ¸å")2472 # çµæ¼çµæåé¢ç輸å
¥å¯ä»¥éå§ç¬è²äº2473 try: # æ¨åæ"ç´æ¥é²å»æ¸çé é¢"çæ¡ä¾ï¼æ以å
ç¨tryé¿éçç2474 where2 = wait_for_element_clickable(2475 driver, "brieftit", 5, By.CLASS_NAME).click()2476 print("é»ææ¸çæ¢ç®")2477 except:2478 pass2479 if org == "åç«æ¨ååé大å¸":2480 where3_xpath = "/html/body/table[9]/tbody/tr[1]/td[2]/a"2481 else:2482 # æä¸æ¸å¨åªè£¡?ï¼xpath_detail2483 where3_xpath = "/html/body/table[9]/tbody/tr/td[1]/table/tbody/tr[1]/td[2]/" + xpath_detail2484 where3 = wait_for_element_clickable(2485 driver, where3_xpath, 5, By.XPATH).click()2486 print("é»æ[æ¸å¨åªè£¡ï¼]")2487 table = wait_for_element_clickable(2488 driver, table_xpath, 5, By.XPATH) # æ¾è¡¨æ ¼ä½ç½®ï¼table_xpath2489 print("æ¾å°è¡¨æ ¼äº")2490 trlist = table.find_elements_by_tag_name('tr')2491 now_url = driver.current_url2492 for row in trlist:2493 tdlist = row.find_elements_by_tag_name('td')2494 for sth in tdlist:2495 new_row = [org, tdlist[index_lst[0]].text,2496 tdlist[index_lst[1]].text, tdlist[index_lst[2]].text, now_url]2497 clickclick_lst.append(new_row)2498 break2499 print(clickclick_lst)2500 except:2501 print("總ä¹æ¯å¤±æäº")2502 table = pd.DataFrame(clickclick_lst)2503 print("åæè¡¨æ ¼")2504 table.rename(columns={0: 'åæ¸é¤¨', 1: '館èå°', 2: 'ç´¢æ¸è',2505 3: '館èçæ
', 4: 'é£çµ'}, inplace=True)2506 print("renameæå")2507 table = statuss(table)2508 return table2509# 馬åé«å¸é¢ MMC V OK2510def MMC(ISBN):2511 sheet = ggSheet()2512 worksheet = sheet.get_worksheet(0)2513 driver = get_chrome()2514 gg = clickclick_crawler(2515 driver,2516 '馬åé«å¸é¢',2517 "http://aleph.library.mmc.edu.tw/F?func=find-b&adjacent=Y&find_code=WRD&local_base=TOP02&request=&TY=",2518 ISBN,2519 "7",2520 "/html/body/form/table[1]/tbody/tr[7]/td/input",2521 "span/a[1]",2522 '/html/body/table[10]',2523 [2, 4, 7]2524 )2525 driver.close()2526 worksheet.append_rows(gg.values.tolist())2527 return gg2528# å·¥æ¥æè¡ç ç©¶é¢ ITRI V2529def ITRI(ISBN):2530 sheet = ggSheet()2531 worksheet = sheet.get_worksheet(0)2532 driver = get_chrome()2533 gg = clickclick_crawler(2534 driver,2535 'å·¥æ¥æè¡ç 究é¢',2536 "http://61.61.255.73/F?func=find-d-0",2537 ISBN,2538 "7",2539 "/html/body/form/table[1]/tbody/tr[9]/td/input",2540 "a/img",2541 '/html/body/table[10]',2542 [5, 2, 8]2543 )2544 driver.close()2545 worksheet.append_rows(gg.values.tolist())2546 return gg2547# æå¿ç§æå¤§å¸ MCUT V2548def MCUT(ISBN):2549 sheet = ggSheet()2550 worksheet = sheet.get_worksheet(0)2551 driver = get_chrome()2552 gg = clickclick_crawler(2553 driver,2554 'æå¿ç§æ大å¸',2555 "https://aleph.lib.cgu.edu.tw/F/?func=find-d-0&local_base=FLY03",2556 ISBN,2557 "7",2558 "/html/body/form/table[1]/tbody/tr[9]/td/input",2559 "a",2560 '/html/body/table[9]',2561 [3, 4, 7]2562 )2563 driver.close()2564 worksheet.append_rows(gg.values.tolist())2565 return gg2566# é·åºç§æå¤§å¸ CGUST V2567def CGUST(ISBN):2568 sheet = ggSheet()2569 worksheet = sheet.get_worksheet(0)2570 driver = get_chrome()2571 gg = clickclick_crawler(2572 driver,2573 'é·åºç§æ大å¸',2574 "https://aleph.lib.cgu.edu.tw/F/?func=find-d-0&local_base=FLY04",2575 ISBN,2576 "7",2577 "/html/body/form/table[1]/tbody/tr[9]/td/input",2578 "a",2579 '/html/body/table[9]',2580 [3, 4, 7]2581 )2582 driver.close()2583 worksheet.append_rows(gg.values.tolist())2584 return gg2585# åç«æ¨ååéå¤§å¸ NCNU V2586def NCNU(ISBN):2587 sheet = ggSheet()2588 worksheet = sheet.get_worksheet(0)2589 driver = get_chrome()2590 gg = clickclick_crawler(2591 driver,2592 'åç«æ¨ååé大å¸',2593 "https://aleph.lib.ncnu.edu.tw/F/?func=find-d-0",2594 ISBN,2595 "7",2596 "/html/body/form/table[1]/tbody/tr[9]/td/input",2597 "",2598 '/html/body/table[11]',2599 [3, 4, 7]2600 )2601 driver.close()2602 worksheet.append_rows(gg.values.tolist())2603 return gg2604# åç«èºåå¤§å¸ NUTN V2605def NUTN(ISBN):2606 sheet = ggSheet()2607 worksheet = sheet.get_worksheet(0)2608 driver = get_chrome()2609 gg = clickclick_crawler(2610 driver,2611 'åç«èºå大å¸',2612 "https://aleph.nutn.edu.tw/F/?func=find-d-0",2613 ISBN,2614 "7",2615 "/html/body/form/table[1]/tbody/tr[9]/td/input",2616 "a",2617 '/html/body/table[9]',2618 [2, 4, 8]2619 )2620 driver.close()2621 worksheet.append_rows(gg.values.tolist())2622 return gg2623# å家å
©å»³é¢ NTCH 9573308436 V2624def NTCH(ISBN):2625 sheet = ggSheet()2626 worksheet = sheet.get_worksheet(0)2627 driver = get_chrome()2628 gg = clickclick_crawler(2629 driver,2630 'å家å
©å»³é¢',2631 "https://opac.npac-ntch.org/F/?func=find-d-0",2632 ISBN,2633 "13",2634 "/html/body/form/table[3]/tbody/tr/td/input",2635 "a[1]",2636 '/html/body/table[9]',2637 [3, 4, 7]2638 )2639 driver.close()2640 worksheet.append_rows(gg.values.tolist())2641 return gg2642# å°ç£ç¥å¸ç 究å¸é¢ TGST V2643def TGST(ISBN):2644 sheet = ggSheet()2645 worksheet = sheet.get_worksheet(0)2646 driver = get_chrome()2647 gg = clickclick_crawler(2648 driver,2649 'å°ç£ç¥å¸ç 究å¸é¢',2650 "http://aleph.flysheet.com.tw/F/?func=find-d-0",2651 ISBN,2652 "7",2653 "/html/body/form/table[1]/tbody/tr[9]/td/input",2654 "a",2655 '/html/body/table[10]',2656 [3, 4, 8]2657 )2658 driver.close()2659 worksheet.append_rows(gg.values.tolist())2660 return gg2661# åç«èºç£ç¾è¡é¤¨ NTMOFA 97848973765472662def NTMOFA(ISBN):2663 sheet = ggSheet()2664 worksheet = sheet.get_worksheet(0)2665 driver = get_chrome()2666 gg = clickclick_crawler(2667 driver,2668 'åç«èºç£ç¾è¡é¤¨',2669 "http://lib.moc.gov.tw/F?func=find-b-0&local_base=THM06",2670 ISBN,2671 "",2672 "a",2673 '/html/body/table[9]'2674 )2675 driver.close()2676 worksheet.append_rows(gg.values.tolist())2677 return gg2678# é«èç§æå¤§å¸ KYU X (æ¨ææ³è¦é£çµçè³æ庫ç®åç¶è·ä¸)2679def KYU(ISBN):2680 sheet = ggSheet()2681 worksheet = sheet.get_worksheet(0)2682 driver = get_chrome()2683 gg = clickclick_crawler(2684 driver,2685 'é«èç§æ大å¸',2686 "http://210.60.92.160/F?func=find-d-0",2687 ISBN,2688 "6",2689 "/html/body/form/table[1]/tbody/tr[8]/td/input",2690 "a",2691 '/html/body/table[8]',2692 [2, 4, 8]2693 )2694 driver.close()2695 worksheet.append_rows(gg.values.tolist())2696 return gg2697# ---------------------------------------é£ä»¥å½¢å®¹|å¾æç¹è²------------------------------------------------2698# chungchung_crawler()2699# ä¸èº|ä¸å·2700def chungchung_crawler(driver, org, org_url, ISBN):2701 driver.get(org_url)2702 search_input = wait_for_element_clickable(driver, "input", 5, By.NAME)2703 search_input.send_keys(ISBN)2704 gogo = wait_for_element_clickable(driver, "query", 5, By.NAME).click()2705 where = wait_for_element_clickable(2706 driver, "body > div > font > font > form > center:nth-child(1) > table > tbody > tr:nth-child(2) > td:nth-child(4) > font > a", 5, By.CSS_SELECTOR).click()2707 table = accurately_find_table_and_read_it(driver, "table", table_index=3)2708 table = organize_columns(table)2709 table.drop([0], inplace=True)2710 table = statuss(table)2711 return table2712# ä¸èºç§æå¤§å¸ CTUST2713def CTUST(ISBN):2714 sheet = ggSheet()2715 worksheet = sheet.get_worksheet(0)2716 driver = get_chrome()2717 gg = chungchung_crawler(2718 driver,2719 'ä¸èºç§æ大å¸',2720 "http://120.107.56.24/isbn1.htm",2721 ISBN2722 )2723 driver.close()2724 worksheet.append_rows(gg.values.tolist())2725 return gg2726# ä¸å·ç§æå¤§å¸ CCUST2727def CCUST(ISBN):2728 sheet = ggSheet()2729 worksheet = sheet.get_worksheet(0)2730 driver = get_chrome()2731 gg = chungchung_crawler(2732 driver,2733 'ä¸å·ç§æ大å¸',2734 "http://163.23.234.194/isbn1.htm",2735 ISBN2736 )2737 driver.close()2738 worksheet.append_rows(gg.values.tolist())2739 return gg2740# éçjsp2741def jing_jsp_crawler(driver, org, org_url, ISBN):2742 function = sys._getframe().f_code.co_name2743 alert_execution_report(function, 100)2744 try:2745 table = []2746 driver.get(org_url)2747 try:2748 select_ISBN_strategy(driver, 'search_field', 'ISBN')2749 except:2750 select_ISBN_strategy(driver, 'search_field', 'STANDARDNO') # åç§å¤§2751 search_ISBN(driver, ISBN, 'search_input')2752 # ä¸ç2753 if wait_for_element_present(driver, 'table.order'):2754 i = 02755 while True:2756 try:2757 datatable = driver.find_element_by_class_name("order")2758 trlist = datatable.find_elements_by_tag_name('tr')2759 df_lst = []2760 for row in trlist:2761 tdlist = row.find_elements_by_tag_name('td')2762 for sth in tdlist:2763 new_row = [org, tdlist[2].text, tdlist[3].text,2764 tdlist[5].text, driver.current_url]2765 df_lst.append(new_row)2766 table.append(df_lst)2767 print(df_lst)2768 wait_for_element_clickable(driver, str(2+i), 2).click()2769 i += 12770 time.sleep(0.5)2771 except:2772 break2773 # å¤çãé¶ç2774 elif wait_for_element_present(driver, 'iframe#leftFrame'):2775 iframe = driver.find_element_by_id('leftFrame')2776 driver.switch_to.frame(iframe)2777 time.sleep(1.5) # åæå° <frame> éè¦æéï¼å¦åæç¡æ³è®å2778 # å¤æ·æ¯ä¸æ¯ï¼é¶çï¼æ¥è©¢çµæ2779 if wait_for_element_present(driver, '#totalpage').text == '0':2780 alert_exception_report(function, 'not found book')2781 return2782 # ï¼å¤çï¼æ¥è©¢çµæ2783 tgt_urls = get_all_tgt_urls(driver)2784 for tgt_url in tgt_urls:2785 driver.get(tgt_url)2786 # çå¾
å
ç´ åºç¾ï¼å¦æåºç¾ï¼é£éº¼æå DataFrameï¼å¦ææ²åºç¾ï¼é£éº¼è·³åºè¿´å2787 if wait_for_element_present(driver, 'table.order'):2788 i = 02789 while True:2790 try:2791 datatable = driver.find_element_by_class_name(2792 "order")2793 trlist = datatable.find_elements_by_tag_name('tr')2794 df_lst = []2795 for row in trlist:2796 tdlist = row.find_elements_by_tag_name('td')2797 for sth in tdlist:2798 new_row = [2799 org, tdlist[2].text, tdlist[3].text, tdlist[5].text, driver.current_url]2800 df_lst.append(new_row)2801 table.append(df_lst)2802 print(df_lst)2803 wait_for_element_clickable(2804 driver, str(2+i), 2).click()2805 i += 12806 time.sleep(0.5)2807 except:2808 break2809 else:2810 continue2811 table = pd.DataFrame(table)2812 print(table)2813 table.rename(columns={0: 'åæ¸é¤¨', 1: '館èå°', 2: 'ç´¢æ¸è',2814 3: '館èçæ
', 4: 'é£çµ'}, inplace=True)2815 except Exception as e:2816 alert_exception_report(function, e, 100)2817 return2818 else:2819 alert_completion_report(function, 100)2820 return table2821# ___________________________________________________2822# æ°åå¸ NewTaipeiCity2823def NewTaipeiCity(ISBN):2824 sheet = ggSheet()2825 worksheet = sheet.get_worksheet(0)2826 driver = get_chrome()2827 all_Insts = []2828 all_Insts.append(2829 webpac_ajax_crawler(2830 driver,2831 'æ°åå¸ç«åæ¸é¤¨',2832 "https://webpac.tphcc.gov.tw/webpac/search.cfm",2833 ISBN2834 )2835 )2836 all_Insts.append(2837 toread_crawler(2838 driver,2839 'æ±åç§æ大å¸',2840 "http://140.129.140.176/toread/opac",...
nqueens.py
Source:nqueens.py
...13 bit = random.randint(0, 1)14 self.chromosome += str(bit)15 else:16 self.chromosome = str(chrome)17 def get_chrome(self):18 return self.chromosome19 def fitness_function(self):20 fitness_sum = 021 for ver in range(0, self.chromosome_len, self.queen_len):22 first_queen = self.chromosome[ver: ver + self.queen_len]23 for hor in range(0, self.chromosome_len, self.queen_len):24 second_queen = self.chromosome[hor: hor + self.queen_len]25 if first_queen == second_queen and ver != hor:26 fitness_sum += 127 if ver != hor and (math.fabs(int(first_queen, 2) - int(second_queen, 2)) ==28 math.fabs(hor / self.queen_len - ver / self.queen_len)):29 fitness_sum += 130 fitness_sum = 8 - fitness_sum / 831 return fitness_sum32 def visualisation(self):33 solution = str()34 visual = str()35 for horizontal in range(0, self.chromosome_len, self.queen_len):36 queen = self.chromosome[horizontal:horizontal + self.queen_len]37 solution += str(int(queen, 2))38 for cell in range(self.queens_number * self.queens_number):39 if cell % 8 == 0:40 visual += '\n'41 if cell % 8 == int(solution[cell // 8]):42 visual += 'Q'43 else:44 visual += '+'45 return visual46class Solver_8_queens:47 def __init__(self, pop_size=100, cross_prob=0.7, mut_prob=0.25):48 self.pop_size = pop_size49 self.cross_prob = cross_prob50 self.mut_prob = mut_prob51 self.population = [Individual() for i in range(pop_size)]52 self.fitness_list = list()53 for ind in self.population:54 self.fitness_list.append(ind.fitness_function())55 def roulette_wheel(self):56 probability = list()57 ind_position = [i for i in range(self.pop_size)]58 fitness_sum = float()59 parents = list()60 for ind in self.fitness_list:61 fitness_sum += ind62 for i in self.fitness_list:63 choose_chance = i / fitness_sum64 probability.append(choose_chance)65 selected_individuals = numpy.random.choice(ind_position, self.pop_size, True, probability)66 for ind in selected_individuals:67 parents.append(self.population[ind])68 return parents69 def reproduce(self, parents):70 chromosome_len = self.population[0].chromosome_len71 next_generation = list()72 for pair in range(len(parents)//2):73 first_parent, second_parent = random.randint(0, len(parents) - 1), random.randint(0, len(parents) - 1)74 while first_parent == second_parent:75 second_parent = random.randint(0, len(parents) - 1)76 cross_prob = random.random()77 if cross_prob <= self.cross_prob:78 cross_point = random.randrange(chromosome_len)79 first_child = Individual(parents[first_parent].get_chrome()[0:cross_point] +80 parents[second_parent].get_chrome()[cross_point:chromosome_len])81 second_child = Individual(parents[second_parent].get_chrome()[0:cross_point] +82 parents[first_parent].get_chrome()[cross_point:chromosome_len])83 else:84 first_child, second_child = parents[first_parent], parents[second_parent]85 next_generation.append(first_child)86 next_generation.append(second_child)87 return next_generation88 def mutation(self, next_generation):89 chromosome_len = self.population[0].chromosome_len90 for ind in range(len(next_generation)):91 if random.random() <= self.mut_prob:92 mutated = random.randrange(chromosome_len)93 mutation = '0'94 if next_generation[ind].get_chrome()[mutated] == '0':95 mutation = '1'96 next_generation[ind] = Individual(next_generation[ind].get_chrome()[0:mutated] + mutation +97 next_generation[ind].get_chrome()[mutated + 1:chromosome_len])98 else:99 next_generation[ind] = Individual(next_generation[ind].get_chrome()[0:mutated] + mutation +100 next_generation[ind].get_chrome()[mutated + 1:chromosome_len])101 return next_generation102 def best_fitness(self):103 best_fitness = max(self.fitness_list)104 best_individual = self.fitness_list.index(best_fitness)105 return best_fitness, best_individual106 def proceed(self):107 parents = self.roulette_wheel()108 next_generation = self.reproduce(parents)109 next_generation = self.mutation(next_generation)110 self.population = next_generation111 for ind in range(len(self.population)):112 self.fitness_list[ind] = self.population[ind].fitness_function()113 def solve(self, min_fitness=7.9, max_epochs=3000):114 best_fitness, best_individual = self.best_fitness()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!