# This creates a directory for our documents and saves each scraped page as a numbered markdown file
output_dir = Path("data/documents")
output_dir.mkdir(parents=True, exist_ok=True)

for i, result in enumerate(batch_job.data):
    filename = f"doc_{i:02d}.md"
    with open(output_dir / filename, "w") as f:
        f.write(result.markdown)
```

<Tip>
  For a more in-depth tutorial on programmatically scraping with Firecrawl, follow Firecrawl's [guide](https://www.firecrawl.dev/blog/best-vector-databases-2025) under the "Building a RAG Pipeline" section.
</Tip>

### Step 2: Set up Pinecone Assistant and index your documents

We'll load those markdown files, chunk them, and store them in Pinecone. First, install the required packages:

```bash
uv pip install langchain-pinecone langchain-openai pinecone langchain langchain-text-splitters
```

Set up your Pinecone API key environment variable:

```bash title=".env"
PINECONE_API_KEY=your-key
```

In your Pinecone Assistant, create a new assistant named "drug-info-rag". The code below indexes your documents in the assistant with their embeddings.

```python
import os
from pathlib import Path
from dotenv import load_dotenv
from pinecone import Pinecone

load_dotenv()