URL Fetch Service
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
واکشی URL
این سرویس به اسکریپت ها اجازه می دهد تا با واکشی URL ها به منابع دیگر در وب دسترسی پیدا کنند. یک اسکریپت می تواند از سرویس UrlFetch برای صدور درخواست های HTTP و HTTPS و دریافت پاسخ ها استفاده کند. سرویس UrlFetch از زیرساخت شبکه Google برای مقاصد کارایی و مقیاسبندی استفاده میکند.
درخواست های ارائه شده با استفاده از این سرویس از مجموعه ای از محدوده های IP سرچشمه می گیرند. در صورت نیاز به لیست سفید یا تأیید این درخواستها، میتوانید فهرست کامل آدرسهای IP را جستجو کنید .
رشته عامل پیشفرض کاربر درخواستهای سرویس UrlFetch Mozilla/5.0 (compatible; Google-Apps-Script; beanserver; +https://script.google.com; id: SCRIPT_ID )
.
این سرویس به محدوده https://www.googleapis.com/auth/script.external_request
نیاز دارد. در بیشتر موارد Apps Script به طور خودکار محدودههایی را که یک اسکریپت نیاز دارد شناسایی کرده و شامل میشود، اما اگر محدودههای خود را به طور صریح تنظیم میکنید، باید به صورت دستی این محدوده را اضافه کنید تا Url Fetch App
استفاده کنید.
همچنین ببینید
کلاس ها
نام | شرح مختصر |
---|
HTTPResponse | این کلاس به کاربران اجازه می دهد تا به اطلاعات خاصی در مورد پاسخ های HTTP دسترسی داشته باشند. |
Url Fetch App | منابع را واکشی کنید و با میزبان های دیگر از طریق اینترنت ارتباط برقرار کنید. |
روش ها
روش | نوع برگشت | شرح مختصر |
---|
get All Headers() | Object | نقشه ویژگی/مقدار سرصفحهها را برای پاسخ HTTP، با سرصفحههایی که مقادیر متعددی بهعنوان آرایه برگردانده شدهاند، برمیگرداند. |
get As(contentType) | Blob | داده های داخل این شی را به عنوان یک حباب تبدیل به نوع محتوای مشخص شده برگردانید. |
get Blob() | Blob | داده های داخل این شی را به صورت حباب برگردانید. |
get Content() | Byte[] | محتوای باینری خام یک پاسخ HTTP را دریافت می کند. |
get Content Text() | String | محتوای یک پاسخ HTTP را به صورت رشته ای کدگذاری می کند. |
get Content Text(charset) | String | محتوای یک پاسخ HTTP را که به عنوان رشته ای از مجموعه نویسه داده شده کدگذاری شده است، برمی گرداند. |
get Headers() | Object | نقشه ویژگی/مقدار سرصفحهها را برای پاسخ HTTP برمیگرداند. |
get Response Code() | Integer | کد وضعیت HTTP (200 برای OK و غیره) یک پاسخ HTTP را دریافت کنید. |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe URL Fetch service enables Apps Script to make HTTP and HTTPS requests to access external web resources, leveraging Google's infrastructure.\u003c/p\u003e\n"],["\u003cp\u003eRequests originate from a specific range of IP addresses, which can be whitelisted if necessary for security purposes.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ehttps://www.googleapis.com/auth/script.external_request\u003c/code\u003e scope is required and often automatically included, but needs manual addition for explicitly set scopes.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eUrlFetchApp\u003c/code\u003e class handles the fetching process with methods like \u003ccode\u003efetch()\u003c/code\u003e and \u003ccode\u003efetchAll()\u003c/code\u003e, while \u003ccode\u003eHTTPResponse\u003c/code\u003e provides access to response data like headers, content, and status codes.\u003c/p\u003e\n"]]],["The UrlFetch service enables scripts to access web resources via HTTP and HTTPS requests, utilizing Google's network infrastructure. Scripts can fetch URLs using `UrlFetchApp` methods like `fetch` and `fetchAll`. IP ranges are provided for whitelisting purposes. The service requires the `https://www.googleapis.com/auth/script.external_request` scope. `HTTPResponse` methods provide ways to extract response data, headers, and status codes. The user agent is `Mozilla/5.0 (compatible; Google-Apps-Script; beanserver)`.\n"],null,["# URL Fetch Service\n\nURL Fetch\n\nThis service allows scripts to access other resources on the web by fetching\nURLs. A script can use the UrlFetch service to issue HTTP and HTTPS requests and\nreceive responses. The UrlFetch service uses Google's network infrastructure for\nefficiency and scaling purposes.\n\nRequests made using this service originate from a set pool of IP ranges. You can [look up the full list of IP addresses](https://www.gstatic.com/ipranges/goog.json)\nif you need to whitelist or approve these requests.\n\nThe default user agent string of UrlFetch service requests is\n`Mozilla/5.0 (compatible; Google-Apps-Script; beanserver; +https://script.google.com; id: `\u003cvar translate=\"no\"\u003eSCRIPT_ID\u003c/var\u003e`)`.\n\nThis service requires the `https://www.googleapis.com/auth/script.external_request`\nscope. In most cases Apps Script automatically detects and includes scopes a script needs, but\nif you are\n[setting your scopes explicitly](/apps-script/concepts/scopes#setting_explicit_scopes)\nyou must manually add this scope to use `Url``Fetch``App`.\n\n#### See also\n\n- [HTTPResponse](/apps-script/reference/url-fetch/http-response)\n- [Setting explicit scopes](/apps-script/concepts/scopes#setting_explicit_scopes)\n\nClasses\n-------\n\n| Name | Brief description |\n|----------------------------------------------------------------|---------------------------------------------------------------------------|\n| [HTTPResponse](/apps-script/reference/url-fetch/http-response) | This class allows users to access specific information on HTTP responses. |\n| [UrlFetchApp](/apps-script/reference/url-fetch/url-fetch-app) | Fetch resources and communicate with other hosts over the Internet. |\n\n[HTTPResponse](/apps-script/reference/url-fetch/http-response)\n--------------------------------------------------------------\n\n### Methods\n\n| Method | Return type | Brief description |\n|--------------------------------------------------------------------------------------------------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------|\n| [getAllHeaders()](/apps-script/reference/url-fetch/http-response#getAllHeaders()) | `Object` | Returns an attribute/value map of headers for the HTTP response, with headers that have multiple values returned as arrays. |\n| [getAs(contentType)](/apps-script/reference/url-fetch/http-response#getAs(String)) | [Blob](../base/blob.html) | Return the data inside this object as a blob converted to the specified content type. |\n| [getBlob()](/apps-script/reference/url-fetch/http-response#getBlob()) | [Blob](../base/blob.html) | Return the data inside this object as a blob. |\n| [getContent()](/apps-script/reference/url-fetch/http-response#getContent()) | `Byte[]` | Gets the raw binary content of an HTTP response. |\n| [getContentText()](/apps-script/reference/url-fetch/http-response#getContentText()) | `String` | Gets the content of an HTTP response encoded as a string. |\n| [getContentText(charset)](/apps-script/reference/url-fetch/http-response#getContentText(String)) | `String` | Returns the content of an HTTP response encoded as a string of the given charset. |\n| [getHeaders()](/apps-script/reference/url-fetch/http-response#getHeaders()) | `Object` | Returns an attribute/value map of headers for the HTTP response. |\n| [getResponseCode()](/apps-script/reference/url-fetch/http-response#getResponseCode()) | `Integer` | Get the HTTP status code (200 for OK, etc.) of an HTTP response. |\n\n[UrlFetchApp](/apps-script/reference/url-fetch/url-fetch-app)\n-------------------------------------------------------------\n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------|------------------------------------------------------------------------------------|\n| [fetch(url)](/apps-script/reference/url-fetch/url-fetch-app#fetch(String)) | [HTTPResponse](/apps-script/reference/url-fetch/http-response) | Makes a request to fetch a URL. |\n| [fetch(url, params)](/apps-script/reference/url-fetch/url-fetch-app#fetch(String,Object)) | [HTTPResponse](/apps-script/reference/url-fetch/http-response) | Makes a request to fetch a URL using optional advanced parameters. |\n| [fetchAll(requests)](/apps-script/reference/url-fetch/url-fetch-app#fetchAll(Object)) | [HTTPResponse[]](/apps-script/reference/url-fetch/http-response) | Makes multiple requests to fetch multiple URLs using optional advanced parameters. |\n| [getRequest(url)](/apps-script/reference/url-fetch/url-fetch-app#getRequest(String)) | `Object` | Returns the request that is made if the operation was invoked. |\n| [getRequest(url, params)](/apps-script/reference/url-fetch/url-fetch-app#getRequest(String,Object)) | `Object` | Returns the request that is made if the operation were invoked. |"]]