2

このコードを使用して、Web サイトから説明を呼び出​​しています。

set astid to AppleScript's text item delimiters

set startHere to "<div id=\"doc-original-text\" itemprop=\"description\">"
set stopHere to "</div>"
set mysource_html to do shell script "curl https://play.google.com/store/movies/details?id=H9EKG4-JHSw"
set AppleScript's text item delimiters to startHere
set blurb1 to text item 2 of mysource_html
set AppleScript's text item delimiters to stopHere
set blurb2 to text item 1 of blurb1

set AppleScript's text item delimiters to astid
blurb2

これはそれが返すものです:

"Liam Neeson stars in producer/director Joe Carnahan&#39;s tense adventure thriller
about a group of tough-as-nails oil rig workers who must fight for their lives in the
Alaskan wilderness after their airplane crashes miles from civilization. With supplies 
running short and hungry wolves closing in, the shaken survivors face a fate worse than 
death if they don&#39;t act fast. Dermot Mulroney, Dallas Roberts, and Frank Grillo co-
star."

返品時では' なく、引用符を正しくフォーマットするにはどうすればよい ですか?&#39;

4

1 に答える 1

1

ASObjC Runnerには、テキストをエンコード/デコードするための便利な機能がいくつかあります。

set astid to AppleScript's text item delimiters

set startHere to "<div id=\"doc-original-text\" itemprop=\"description\">"
set stopHere to "</div>"
set mysource_html to do shell script "curl https://play.google.com/store/movies/details?id=H9EKG4-JHSw"
set AppleScript's text item delimiters to startHere
set blurb1 to text item 2 of mysource_html
set AppleScript's text item delimiters to stopHere
set blurb2 to text item 1 of blurb1

set AppleScript's text item delimiters to astid
tell application "ASObjC Runner" to set blurb3 to modify string blurb2 so it is unencoded for XML

または、テキスト項目の区切り記号を引き続き使用できます。

set astid to AppleScript's text item delimiters

set startHere to "<div id=\"doc-original-text\" itemprop=\"description\">"
set stopHere to "</div>"
set mysource_html to do shell script "curl https://play.google.com/store/movies/details?id=H9EKG4-JHSw"
set AppleScript's text item delimiters to startHere
set blurb1 to text item 2 of mysource_html
set AppleScript's text item delimiters to stopHere
set blurb2 to text item 1 of blurb1
set AppleScript's text item delimiters to "&#39;"
set blurb2 to text items of blurb2
set AppleScript's text item delimiters to "'"
set blurb2 to blurb2 as text
set AppleScript's text item delimiters to astid
于 2012-11-20T22:30:31.507 に答える