如何从rss获取原型数据.文件吗?



我有1个rss文件,我想从这里获得包括html代码的数据。我尝试了从表中IMPORTFEED,但它没有显示我想要的html代码。

下面是我的rss示例文件:

<channel>
<item>
<title>5 Small Business Digital Marketing Tips | Donklephant</title>
<link>https://www.google.com/url?rct=j&sa=t&url=https://donklephant.com/5-small-business-digital-marketing-tips/&ct=ga&cd=CAIyGjRkOWNlYjEwZThmZWEzYzk6Y29tOmVuOlVT&usg=AFQjCNG2rQuRDUiY_UppXg7LAt5uw1ZDXQ</link>
<dc:identifier/>
<pubDate>Sun, 03 Oct 2021 07:26:15 +0000</pubDate>
<dc:creator/>
<guid isPermaLink="true">https://www.google.com/url?rct=j&amp;sa=t&amp;url=https://donklephant.com/5-small-business-digital-marketing-tips/&amp;ct=ga&amp;cd=CAIyGjRkOWNlYjEwZThmZWEzYzk6Y29tOmVuOlVT&amp;usg=AFQjCNG2rQuRDUiY_UppXg7LAt5uw1ZDXQ</guid>
<description>Getting leads and sales is sometimes more difficult than business owners expect. In fact, about 65% of businesses say it’s their biggest marketing challenge. With a strong digital marketing strategy, however, you don’t have to struggle.  Here are five digital marketing tips that can set your...</description>
<content:encoded><div><img src="https://donklephant.com/wp-content/uploads/2021/10/01425af1e662eeeada815f0cad2f9746.jpeg" class="ff-og-image-inserted"></div><p>Getting leads and sales is sometimes more difficult than business owners expect. In fact, about <a href="https://www.smallbizgenius.net/by-the-numbers/lead-nurturing-statistics/#gref">65% of businesses</a> say it’s their biggest marketing challenge. With a strong digital marketing strategy, however, you don’t have to struggle. </p> <p>Here are five digital marketing tips that can set your business up for growth and lasting success. With this digital marketing advice, you can get ahead of the competition. You can retain repeat customers to improve your ROI, too.</p> <p>Set your business up for growth this year. Develop your digital marketing plan with these five tips today. </p> <h2><span>1. Establish Brand Guidelines</span></h2> <p>A distinct brand will help your business stand out from the competition. Otherwise, consumers might not even realize you exist. Take the time to establish brand guidelines before developing your digital marketing plan.</p> <p>Your guidelines should outline your:</p> <ul> <li>Mission statement</li> <li>Vision statement</li> <li>Personality</li> <li>Voice</li> <li>Tone</li> <li>Color palette</li> <li>Photography/imagery styles</li> <li>Logo styles</li> <li>Font styles</li> </ul> <p>Make sure to maintain brand consistency as you use the rest of this digital marketing advice. Consistency will help awareness grow into recognition. People will start recognizing your materials through your visual brand. </p> <h2><span>2. Update Your Website</span></h2> <p>Take the time to update your website as well. An old, slow, outdated website could cost you customers.</p> <p>In fact, <a href="https://fitsmallbusiness.com/website-statistics/">38% of consumers</a> stop interacting with poorly designed websites. They might judge your credibility based on your site, too.</p> <p>Instead, update your website by following the latest user experience design trends. Make sure your site is fast and mobile-ready, too. </p> <p>You can learn how to get the most from your <a href="https://stephenholmes.co.uk/how-to-get-the-most-from-your-web-design/">web design</a> here.</p> <h2><span>3. Create Content</span></h2> <p>Once you update your website, add content creation to your digital marketing strategy. Then, optimize your content for search engine optimization (SEO).</p> <p>SEO will help people find your website when they search for your product or service online.</p> <h2><span>4. Gather and Nurture Leads</span></h2> <p>As you use these digital marketing tips, make sure you have a plan for generating leads.</p> <p>For example, you can add a form to your website. Consider using a chatbot or lead magnets as well.</p> <p>Once you start gathering leads, use business marketing strategies like email marketing to nurture them. Email marketing will help you remain top of mind. </p> <h2><span>5. Stay Social</span></h2> <p>Don’t neglect social media! Adding social media to your digital marketing plan will help you engage your target audience.</p> <p>Reformat your blog posts for social media. Once people comment on your posts, respond! Create two-way conversations and engage your customer.</p> <p>Otherwise, use influencer marketing to expand your reach online. </p> <p>Keep up-to-date with the latest trends, too. For example, video content is becoming more popular. AR and VR are gaining popularity, too.</p> <p>Keeping up with the trends will show consumers you’re relevant. </p> <h2><span>Get Growing: 5 Digital Marketing Tips for Your Small Business</span></h2> <p>Don’t let your digital marketing strategy grow stale. Instead, use these digital marketing tips to expand your reach online. With these tips, you can market your services and boost brand awareness.</p> <p>Start generating more leads and sales with these business marketing tips today.</p> <p>Hunting for more tips? You’ve come to the right place.</p> <p>Check out our latest guides for more useful advice. </p></content:encoded>
</item>
</channel>

我想让content:编码的数据包括html标签:

<img src="https://donklephant.com/wp-content/uploads/2021/10/01425af1e662eeeada815f0cad2f9746.jpeg" class="ff-og-image-inserted"></div><p>Getting leads and sales is sometimes more difficult than business owners expect. In fact, about <a href="https://www.smallbizgenius.net/by-the-numbers/lead-nurturing-statistics/#gref">65% of businesses</a> say it’s their biggest marketing challenge. With a strong digital marketing strategy, however, you don’t have to struggle. </p> <p>Here are five digital marketing tips that can set your business up for growth and lasting success. With this digital marketing advice, you can get ahead of the competition. You can retain repeat customers to improve your ROI, too.</p> <p>Set your business up for growth this year. Develop your digital marketing plan with these five tips today. </p> <h2><span>1. Establish Brand Guidelines</span></h2> <p>A distinct brand will help your business stand out from the competition. Otherwise, consumers might not even realize you exist. Take the time to establish brand guidelines before developing your digital marketing plan.</p> <p>Your guidelines should outline your:</p> <ul> <li>Mission statement</li> <li>Vision statement</li> <li>Personality</li> <li>Voice</li> <li>Tone</li> <li>Color palette</li> <li>Photography/imagery styles</li> <li>Logo styles</li> <li>Font styles</li> </ul> <p>Make sure to maintain brand consistency as you use the rest of this digital marketing advice. Consistency will help awareness grow into recognition. People will start recognizing your materials through your visual brand. </p> <h2><span>2. Update Your Website</span></h2> <p>Take the time to update your website as well. An old, slow, outdated website could cost you customers.</p> <p>In fact, <a href="https://fitsmallbusiness.com/website-statistics/">38% of consumers</a> stop interacting with poorly designed websites. They might judge your credibility based on your site, too.</p> <p>Instead, update your website by following the latest user experience design trends. Make sure your site is fast and mobile-ready, too. </p> <p>You can learn how to get the most from your <a href="https://stephenholmes.co.uk/how-to-get-the-most-from-your-web-design/">web design</a> here.</p> <h2><span>3. Create Content</span></h2> <p>Once you update your website, add content creation to your digital marketing strategy. Then, optimize your content for search engine optimization (SEO).</p> <p>SEO will help people find your website when they search for your product or service online.</p> <h2><span>4. Gather and Nurture Leads</span></h2> <p>As you use these digital marketing tips, make sure you have a plan for generating leads.</p> <p>For example, you can add a form to your website. Consider using a chatbot or lead magnets as well.</p> <p>Once you start gathering leads, use business marketing strategies like email marketing to nurture them. Email marketing will help you remain top of mind. </p> <h2><span>5. Stay Social</span></h2> <p>Don’t neglect social media! Adding social media to your digital marketing plan will help you engage your target audience.</p> <p>Reformat your blog posts for social media. Once people comment on your posts, respond! Create two-way conversations and engage your customer.</p> <p>Otherwise, use influencer marketing to expand your reach online. </p> <p>Keep up-to-date with the latest trends, too. For example, video content is becoming more popular. AR and VR are gaining popularity, too.</p> <p>Keeping up with the trends will show consumers you’re relevant. </p> <h2><span>Get Growing: 5 Digital Marketing Tips for Your Small Business</span></h2> <p>Don’t let your digital marketing strategy grow stale. Instead, use these digital marketing tips to expand your reach online. With these tips, you can market your services and boost brand awareness.</p> <p>Start generating more leads and sales with these business marketing tips today.</p> <p>Hunting for more tips? You’ve come to the right place.</p> <p>Check out our latest guides for more useful advice. </p>

请帮帮我!

更新:@Tanaike下面是我的RSS网址。它有许多项目。

https://cdn.feedcontrol.net/1830/2857-8L5Ntr0N5l5Xf.xml

我真正的意图是得到每个项目的<title><content:encoded>来创建一个Google Docs文件。我想要那个文档文件保持它的结构。

所以我尝试了你的帮助,但它不工作,因为我想。

function myFunction() {
const url = "https://cdn.feedcontrol.net/1830/2857-8L5Ntr0N5l5Xf.xml"; // Please set URL.
const data = UrlFetchApp.fetch(url).getContentText();
const res = data.match(/<content:encoded>([sSw]+)</content:encoded>/);
Logger.log(res)
if (res) {
var blob1 = Utilities.newBlob("").setDataFromString(res[1], "UTF-8").setContentType("text/html");
Drive.Files.insert({title: "TEST"}, blob1, {convert: true});
//DriveApp.createFile("sample.html", res[1], MimeType.HTML);
}
}

期待您的帮助。

我相信你的目标如下。

  • 你有一个文件在Google Drive.
  • 您希望使用Google Apps Script检索<content:encoded>###</content:encoded>###的值。

当我测试您的数据时,不幸的是,由于解析错误,数据无法由XmlService解析。因此,在这个答案中,我使用正则表达式来检索您需要的值。示例脚本如下:

示例脚本:

function myFunction() {
const fileId = "###"; // Please set the file ID of the file including the data.
const data = DriveApp.getFileById(fileId).getBlob().getDataAsString();
const res = data.match(/<content:encoded>([sSw]+)</content:encoded>/);
if (res) {
DriveApp.createFile("sample.html", res[1], MimeType.HTML);
}
}
  • 运行此脚本时,打开包含数据的文件并检索数据,检索<content:encoded>###</content:encoded>中的###的值。然后,检索到的数据作为HTML文件输出到根文件夹。

  • 如果您的数据需要从网站检索,请按以下方式修改data

    function myFunction() {
    const url = "###"; // Please set URL.
    const data = UrlFetchApp.fetch(url).getContentText();
    const res = data.match(/<content:encoded>([sSw]+)</content:encoded>/);
    if (res) {
    DriveApp.createFile("sample.html", res[1], MimeType.HTML);
    }
    }
    

引用:

  • getFileById (id)
  • createFile(name, content, mimeType)

编辑:

从你更新的问题和你下面的评论,

我真正的意图是得到每个项目的和内容编码,以创建一个Google Docs文件。我想要那个文档文件保持它的结构。

我想从那个RSS生成google Docs。例如,对于第一个项目,我想用项目的名称创建一个Docs文件。文档文件包含项目的内容:编码的内容。这是我想要的输出文档文件:https://docs.google.com/document/d/1DjPmBSZWoKcvJpuBssQ_3YtxwQrV2eg4QO6VUZqxMsQ/edit?usp=sharing。希望你能理解,因为我的英语是从谷歌翻译过来的。

我明白你最初的问题是不同于你的实际问题。在这种情况下,我认为可以将HTML转换为Google Document,但由于Google方面的当前规范,输出结果可能与您的目标不同。因此,请测试以下示例脚本。

示例脚本1:在这个脚本中,Google Document通过<title><content:encoded>的值被创建到根文件夹。但是,我认为从HTML数据转换的输出Google Document可能与您的目标不同。

function myFunction1() {
const url = "https://cdn.feedcontrol.net/1830/2857-8L5Ntr0N5l5Xf.xml";
const data = UrlFetchApp.fetch(url).getContentText();
const root = XmlService.parse(data).getRootElement();
const ns1 = root.getNamespace();
const ns2 = XmlService.getNamespace("http://purl.org/rss/1.0/modules/content/");
root.getChild("channel", ns1).getChildren("item", ns1).forEach(e => {
Drive.Files.insert({title: e.getChild("title", ns1).getValue(), mimeType: MimeType.GOOGLE_DOCS}, HtmlService.createHtmlOutput(e.getChild("encoded", ns2).getValue()).getBlob());
});
}

示例脚本2:在此脚本中,PDF文件通过<title><content:encoded>的值创建到根文件夹。我认为从HTML数据转换的输出PDF文件可能与您的目标相同。但是,mime类型不是Google Document。

function myFunction2() {
const url = "https://cdn.feedcontrol.net/1830/2857-8L5Ntr0N5l5Xf.xml";
const data = UrlFetchApp.fetch(url).getContentText();
const root = XmlService.parse(data).getRootElement();
const ns1 = root.getNamespace();
const ns2 = XmlService.getNamespace("http://purl.org/rss/1.0/modules/content/");
root.getChild("channel", ns1).getChildren("item", ns1).forEach(e => {
let html = e.getChild("encoded", ns2).getValue();
const url = html.match(/<img src="([sSw]+?)"/);
if (url) {
const blob = UrlFetchApp.fetch(url[1].replace(/&amp;/g, "&").trim()).getBlob();
const base64 = blob.getContentType() + ';base64,'+ Utilities.base64Encode(blob.getBytes());
html = html.replace(/<img src="[sSw]+?>/, `<img src="data:${base64}">`);
}
DriveApp.createFile(HtmlService.createHtmlOutput(html).getAs(MimeType.PDF).setName(e.getChild("title", ns1).getValue()));
});
}