nofearbutlove / bible-clipper

It gets contents of the Bible from web, and put it to machine's clipboard.
MIT License
0 stars 1 forks source link

Change english bible web source to biblegateway.com! #3

Open JmyL opened 7 years ago

JmyL commented 7 years ago

/cc @youngerous

URL is like this.

https://www.biblegateway.com/passage/?search=#{bible_english_code}#{chapter}&version=#{translation_code}

'translation_code' 는 소문자도 관계 없네요. 아래는 예제입니다.

https://www.biblegateway.com/passage/?search=gen1&version=esv
JmyL commented 7 years ago

흠... 영어는 좀 아닌 듯 ㅋㅋㅋ

가져와야 하는 https://www.biblegateway.com/passage/?search=gen1&version=ESV 페이지의 contents는 다음과 같습니다.

<p class="chapter-1">
    <span class="text Gen-1-1">
        <span class="chapternum">1 </span>
        In the <sup class='crossreference' data-link='(&lt;a href=&quot;#cen-ESV-1A&quot; title=&quot;See cross-reference A&quot;&gt;A&lt;/a&gt;)' data-cr='#cen-ESV-1A'></sup>beginning, God created the heavens and the earth.
    </span> 
    <span id="en-ESV-2" class="text Gen-1-2">
        <sup class="versenum">2 </sup>The earth was <sup class='crossreference'  data-link='(&lt;a href=&quot;#cen-ESV-2B&quot; title=&quot;See cross-reference B&quot;&gt;B&lt;/a&gt;)' data-cr='#cen-ESV-2B'></sup>without form and void, and darkness was over the face of the deep. And the Spirit of God was hovering over the face of the waters.
    </span>
</p>
<p>
    <span id="en-ESV-3" class="text Gen-1-3">
        <sup class="versenum">3 </sup>And God said, <sup class='crossreference'  data-link='(&lt;a href=&quot;#cen-ESV-3C&quot; title=&quot;See cross-reference C&quot;&gt;C&lt;/a&gt;)' data-cr='#cen-ESV-3C'></sup>“Let there be light,” and there was light.
    </span>    
    <span id="en-ESV-4" class="text Gen-1-4">
        <sup class="versenum">4 </sup>And God saw that the light was good. And God separated the light from the darkness.</span> <span id="en-ESV-5" class="text Gen-1-5"><sup class="versenum">5 </sup>God called the light Day, and the darkness he called Night. And there was evening and there was morning, the first day.
    </span>
</p>
JmyL commented 7 years ago

chapter-* class의 p tag 안에, text class의 span을 뽑아내야 하는군요.

JmyL commented 7 years ago

이 사이트는 강적입니다! 아마도 crolling 하지 못하게 막은 듯 한데, 다음과 같은 error가 나네요.

C:/RailsInstaller/Ruby2.3.0/lib/ruby/2.3.0/open-uri.rb:225:in `open_loop': redirection forbidden: http://www.biblegateway.com/passage/?search=luk1&version=NIV -> https://www.biblegateway.com/passage/?search=luk1&version=NIV (RuntimeError)