Create browseruseforweb.py

init
This commit is contained in:
AiShell 2025-02-28 10:38:21 +08:00 committed by GitHub
parent d812d5b861
commit 501e953fc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

39
Tools/browseruseforweb.py Normal file
View File

@ -0,0 +1,39 @@
import asyncio
import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from pydantic import SecretStr
from browser_use import Agent
# dotenv
load_dotenv()
api_key = os.getenv('api_key', '')
if not api_key:
raise ValueError('DEEPSEEK_API_KEY is not set')
async def run_search():
agent = Agent(
task=(
'1. 连接http://192.168.3.93/dvwa/index.php '
'2. 这是一个DVWA的靶机使用默认密码登录'
'3. 登录后选择Sql Injecttion,给出解法并实现,所有描述请使用中文'
),
llm=ChatOpenAI(
base_url='https://api.deepseek.com/v1',
model='deepseek-chat',
api_key=SecretStr(api_key),
),
use_vision=False,
)
await agent.run()
if __name__ == '__main__':
asyncio.run(run_search())