# 标准功能

我们为您精选了一系列主流的开源技术框架作为选择参考，例如 Puppeteer 与 Playwright 等，您可以根据需求灵活选用。

这些工具所涵盖的各项浏览器自动化能力，在我们的 浏览器API 中已得到完整支持。这意味着，在使用过程中，你可以直接查阅对应技术的官方文档，所有功能均可无缝适配、顺利调用，获取可靠的技术支持将更加轻松便捷。

### **技术栈** <a href="#ji-shu-zhan" id="ji-shu-zhan"></a>

[**Puppeteer**](https://pptr.dev/api/puppeteer.puppeteernode)

{% tabs %}
{% tab title="New Page" %}

```sh
const page = await page.newPage();  
await page.goto('https://example.com');  
```

{% endtab %}

{% tab title="Get Screenshot" %}

```python
await page.screenshot({ path: 'screenshot.png', fullPage: true });
```

{% endtab %}

{% tab title="Get HTML" %}

```csharp
const page = await browser.newPage();  
await page.goto('https://example.com');  
const html = await page.content();
```

{% endtab %}

{% tab title="Click on Element" %}

```go
// Wait and click on first result.
await page.locator('.devsite-result-item-link').click()
```

{% endtab %}
{% endtabs %}

[**Selenium**](https://www.selenium.dev/documentation/)

{% tabs %}
{% tab title="Python" %}

```python

# Start the session
driver = webdriver.Chrome()

# Take action on browser
driver.get("https://www.selenium.dev/selenium/web/web-form.html")

# Request browser information
title = driver.title
driver.implicitly_wait(0.5)

#Find an element
text_box = driver.find_element(by=By.NAME, value="my-text")
submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button")

# Take action on element
text_box.send_keys("Selenium")
submit_button.click()

# Request element information
message = driver.find_element(by=By.ID, value="message")
text = message.text

# End the session
driver.quit()
```

{% endtab %}

{% tab title="NodeJS" %}

```glimmer-js
 // Start the Browser
 driver = await new Builder().forBrowser(Browser.CHROME).build();
 
 // GOTO UTL on browser
 await driver.get('https://www.selenium.dev/selenium/web/web-form.html');
 
 // Request browser information
 let title = await driver.getTitle();
 
 // Waiting
 await driver.manage().setTimeouts({implicit: 500});
 
 // Find an element
 let textBox = await driver.findElement(By.name('my-text'));
 let submitButton = await driver.findElement(By.css('button'));

 // Take action on element
 await textBox.sendKeys('Selenium');
 await submitButton.click();
 
 // Request element information   
 let message = await driver.findElement(By.id('message'));
 let value = await message.getText();
 
 // End the session   
 await driver.quit();
```

{% endtab %}
{% endtabs %}

### **运行** <a href="#yun-xing" id="yun-xing"></a>

保存以下代码（不要忘记输入您的凭证！），并使用以下命令运行它：script.js

{% tabs %}
{% tab title="Python" %}

```python

# Start the session
driver = webdriver.Chrome()

# Take action on browser
driver.get("https://www.selenium.dev/selenium/web/web-form.html")

# Request browser information
title = driver.title
driver.implicitly_wait(0.5)

#Find an element
text_box = driver.find_element(by=By.NAME, value="my-text")
submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button")

# Take action on element
text_box.send_keys("Selenium")
submit_button.click()

# Request element information
message = driver.find_element(by=By.ID, value="message")
text = message.text

# End the session
driver.quit()


```

{% endtab %}

{% tab title="NodeJS" %}

```glimmer-js

 // Start the Browser
 driver = await new Builder().forBrowser(Browser.CHROME).build();
 
 // GOTO UTL on browser
 await driver.get('https://www.selenium.dev/selenium/web/web-form.html');
 
 // Request browser information
 let title = await driver.getTitle();
 
 // Waiting
 await driver.manage().setTimeouts({implicit: 500});
 
 // Find an element
 let textBox = await driver.findElement(By.name('my-text'));
 let submitButton = await driver.findElement(By.css('button'));

 // Take action on element
 await textBox.sendKeys('Selenium');
 await submitButton.click();
 
 // Request element information   
 let message = await driver.findElement(By.id('message'));
 let value = await message.getText();
 
 // End the session   
 await driver.quit();
```

{% endtab %}
{% endtabs %}

如果您需要进一步说明方面的帮助，请随时通过以下方式与我们联系： [**support@thordata.com**](https://mailto:support@thordata.com/).
